I apologize if this question was already asked but I can’t seem to find exactly what I am looking for. I want to be able to find files in XP (using cmd) that are older than a specific date. I want to do something like DIR/FIND files that are older than 30 days.
The following does not work but hopefully it will give you an idea of what I am trying to do.
FOR /f %%f IN ('DIR /b /t -30 I:\FOLDER1\*.pdf') DO move /Y Z:\FOLDER1\%%f "I:\FOLDER2\"
Thanks!
Julian date function are taken from DosTips.com function library
First use XCOPY /L /D to get list of files that have been modified within past 30 days: save to an exclude list.
Then use XCOPY /L to get all files and pipe through FINDSTR to exclude the files from the exclude list and save results to an include list.
Finally loop through include list and move the files
I did not use the XCOPY /EXCLUDE option because it treats the files as having implicit wildcards. So if you specified * instead of *.pdf, then an excluded file named TEST would also cause files named TEST1, TEST.TXT, and TEST.EXE to be excluded as well.
The FINDSTR /I option is required to compensate for a FINDSTR bug when doing a search with multiple literal search strings. The /I option shouldn’t be required, but doing a case sensitive search with multiple literal search strings can give the wrong result.