How can I copy files that were created within X days using batch script?
I am trying to make a daily backup batch for files created or modified within last 45 days, but I can't seem to find anything about copying files that were created within 45 days.
Is there any (preferably easy) way to copy files created or modified within X days and purging ones that were created or modified before X days in a batch?
So far I have this:
::Delete older than 45 days:
forfiles /p S:\ /s /D -45 /C "cmd /c del /a rhiosal/q @path&echo @path"
::Clear out empty folders:
robocopy S:\D S:\D /S /move
robocopy S:\E S:\E /S /move
::Copy modified withing 45 days:
ROBOCOPY "D:" "S:\D" *.* /S /DCOPY:T /COPYALL /MAXAGE:45 /ETA /PURGE /XD "$recycle.bin" /XD "System Volume Information"
ROBOCOPY "E:" "S:\E" *.* /S /DCOPY:T /COPYALL /MAXAGE:45 /ETA /PURGE /XD "$recycle.bin" /XD "System Volume Information"
Thank you.