C:\scripts>more cleanup_display.bat
@ECHO OFF
SETLOCAL
SET targetPath=C:\scripts\scripts\logs
SET targetFiles=*.log
SET aMonthBefore=20090214
FOR /f %%z IN ('dir /b %targetPath%\%targetFiles%') DO (
FOR /f "tokens=1-4 delims=/ " %%a IN ('dir %targetPath%\%%z') DO (
IF "%%c%%a%%b" LSS "9" (
FOR /f "tokens=1-4 delims=(" %%1 IN ("%%c%%a%%b") DO (
IF "%%2"=="" (
IF %%c%%a%%b LSS %aMonthBefore% (
ECHO Detect file older than %aMonthBefore% ::::: -- %%z -- %%c%%a%%b
) ELSE (
ECHO Defect file newer than %aMonthBefore% ::::: -- %%z -- %%c%%a%%b
)
)
)
)
)
)
C:\scripts>dir C:\scripts\scripts\logs\*.log
Volume in drive C has no label.
Volume Serial Number is 0D38-406F
Directory of C:\scripts\scripts\logs
07/22/2008 08:50 PM 16,640 bck_20080722.log
07/24/2008 03:36 PM 1,067 bck_20080724.log
02/18/2009 11:07 AM 0 msms.log
3 File(s) 17,707 bytes
0 Dir(s) 47,139,299,328 bytes free
C:\scripts>cleanup_display.bat
Detect file older than 20090214 ::::: -- bck_20080722.log -- 20080722
Detect file older than 20090214 ::::: -- bck_20080724.log -- 20080724
Defect file newer than 20090214 ::::: -- msms.log -- 20090218