View Single Post
  #4 (permalink)  
Old 07-15-2009, 04:06 PM
hdawg's Avatar
hdawg hdawg is offline
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147

Originally Posted by jdizzle View Post
Very good stuff, but one comment, one question on this:

If you want to have it delete files older then 90 days, you need to move the line
forfiles.exe -p. -s -m*.txt -d-10 -c"zip -m @FILE"
to the end (after the 4 lines to delete files); otherwise, it zips everything older then 10 days, then when it gets to the lines to find files older then 90 days, it doesn't find anything because zipping the files changed the modified date on all of them.
the del for *.txt really I guess is irrelevant since the files are getting zipped anyway. But yes, it'd need to be moved to be effective for that.

Should the lines to delete files also delete the folders? Once I figured out that the zip portion needed to come after the delete portion, it still doesn't appear to be removing the older folders--not sure if I did something to cause this, or if it doesn't delete them by design.
forfiles.exe -p. -s -d-90 -m*.* -c"cmd /c if @ISDIR==TRUE rd /q @FILE"

^^ should delete the folders.
Reply With Quote