Monday, 26 August 2013

Batch files to list files saved in last 24 hours

Batch files to list files saved in last 24 hours

Hi I'm trying to write a batch files that will search some directories and
output a text file report with a list of files saved in the last day
between a certain file size.
The files size part is no problem - but how to I parse the date and check
it against todays date, and add it to the 'if' statement?
This is what I have so far:
@echo Report will open when complete
@echo Working
@echo off
setlocal
set "SEARCH_DIR=f:"
set "MIN_SIZE=1"
set "MAX_SIZE=300000"
set "REPORT=F:\Error_report.txt"
echo **************************************************** >> %REPORT%
echo File report %date% %time% >> %REPORT%
echo File size %MIN_SIZE% to %MAX_SIZE% >> %REPORT%
echo **************************************************** >> %REPORT%
echo File list: >> %REPORT%
for /R "%SEARCH_DIR%" %%F in (*) do (
if exist "%%F" if %%~zF LSS %MAX_SIZE% if %%~zF GEQ %MIN_SIZE% echo %%F
>> %REPORT%
)
@echo Done
START %REPORT%
I've tried adding if forfiles /d +1 to the if statement - but that doesn't
work!
Any help would be appreciated.

No comments:

Post a Comment