find ./ -ctime +7 -exec rm -f {} \; -lsThis should print the names of and delete all files within or under the root directory created more than 7 days ago. Cygwin also includes a cron utility so it would be rather straightforward to accomplish your goal this way if I understand your question correctly. (Be aware that you should be very sure that the logic embodied in your predicates is correct when executing rm -f in an automated fashion :)forfiles /P PATHTOFOLDER /S /D -30 /M *.* /C "cmd /C del @path /Q"
Where PATHTOFOLDER is the full path to the directory in question (c:\windows\temp in your case?), the /S means "... and all subdirectories" if desirable, and the -30 after /D is "older than 30 days"; you can change to -10 if you want 10 days, etc. /M is file mask (*.* for all files) and /C is the command you'd run on any file matching these parameters, in this case "delete" with the /Q switch to avoid prompting.forfiles /P PATHTOFOLDER /D -30 /M *.* /C "cmd /C del @path /Q"
forfiles /P PATHTOFOLDER /S /D -30 /M *.* /C "cmd /C rd @path /Q"Try this on a copy of a folder first to test it out... I can't stress this enough, copy some folder to c:\TEST or something, and try all your batch jobs out there as the PATHTOFOLDER, so you're sure you've done the syntax as I have above and it works... before you point it at any actual directory for the love of god and all that is holy.at 9:00a /every:Su,M,T,W,Th,F,S c:\scripts\CleanTemp.batwhere c:\scripts\cleantemp.bat is the full path to the batch file. This will run it automatically at 9am every single day. You can type AT at the command line with no arguments to see any existing schedule jobs. Adjust to taste, add seasoning.
I don't get it. Files that are older than a certain interval period, like in a temp directory, or files that are set to delete at a certain datetime, like cookies, or all the files created or modified during a certain interval, like a system restore, or what?
posted by ChasFile at 6:38 PM on March 25, 2006