forfiles /D +12/1/%2 /C "cmd /c if /I @FDATE LEQ 12/31/%2 move @file %3\Archive\12-%2 >NUL"
The forfiles is supposed to be targeting all files with last modified dates between 12/1/2015 and 12/31/2015 (including the 1st and 31st), and moving them to archive. For reasons unknown, some files with the last modified date 12/3/2015, and 12/9/2015 are not being moved. Additionally, ALL files with last modified date of 12/4/2015 thru 12/8/2015 are not being moved.
Steps taken to debug: Processed different months: January, Feb, etc and Archiving was successful. Permissions have been checked, and verified. Manually archived the unmoved files. Created copies of the unmoved files and still encounter the same issues. The last thing I did was replace
if /I @FDATE LEQ 12/31/%2 move @file %3\Archive\12-%2 >NUL
with
echo @FDATE
to ensure that ALL the modified dates are visible. Modified dates for the files that aren't being successfully moved and archived are visible.
Here's what I FINALLY got to work:
For me, this is to move spreadsheets (.xls) that are 90 day old or older (/D -90) to the old backups folder. @file is any file in the directory that meets this criteria. The %backups% variable is not important for this command, it just saves me time when I'm doing a lot of these. The SET line is its own line. And from Forfiles to the end is its own line.
I hope this helps, have fun!