how to search for a particular folder

November 30, 2009 at 03:10:18
Specs: Windows XP, 512mb
hi , i have many folders called LIB in my drive
say it can be as LIB_data,lib,lib_ac anything that starts with lib or LIB... i want to list all these directories and sort them in which they have created in the pc and copy the latest directory contents to BATCH_LATEST_LIB_FILES folder,that will be a new folder created by this batch file.i want this new folder to be created in the path where this batch file is present. please help me with a batch script.

See More: how to search for a particular folder

Report •

December 1, 2009 at 14:48:20
(not tested, might have bugs, be careful)

setlocal enabledelayedexpansion
set dt=
pushd "\"
for /f "tokens=* delims=" %%a in ('dir /s /a:d lib*') do (
set cc=%%a
set dd=!cc:~0,1!
if "!dd!" equ " " (
set dd=!cc:~0,14!
if "!dd!" equ " Directory of " set dd=!cc:~14!
) else (
set vv=!cc:~39!
set cc=!cc:~6,4!!cc:~0,5!
if "!cc!" gtr "!dt!" (
set dt=!cc!
set pat=!dd!
set ff=!vv!)
echo lib files dated: !cc! fullpath: !pat!\!ff!
copy /y !pat!\!ff!\*.* .\BATCH_LATEST_LIB_FILES

Report •
Related Solutions

Ask Question