In Windows, is there an easy way to say “delete all the files in a particular directory which are older than 14 days old”, or something of that sort?
It seems like it ought to be trivially easy, but I can’t figure out a quick way to do it without writing a nastily intricate batch file. And of course, anything that involves recursively and automatically deleting files is NOT something you want to get wrong.
You can always do this manually in Windows Explorer by clicking on the Date Modified column to sort in date order, then you can highlight everything older than a given date and delete those files.
Don’t forget that ‘last modified’ doesn’t necessarily mean ‘last used’ - there is a ‘last accessed’ timestamp, but I’m not sure that will help either if, for example, the disk indexing service, or your antivirus software causes it to be updated every time it does a scan.
One way I have found to sort-of deal with such uncertainty is to first make an archive copy of the files suspected to be redundant, then just rename or move them; if they were required, it will quickly become evident; if not, they can be deleted after a reasonable buffer time.
On our servers we use a little exe called LogClean.exe that we got free from somewhere. It includes the exe and then instructions on how to write a .bat, and also logs its doings in a log file. We run the bat from Scheduled Tasks (it doesn’t have to be scheduled, though)
We use it to delete IIS log files and SQL baks over 15 days old. Works great for us.
But I can’t seem to find it anywhere, not even SourceForge. Email or PM me if you want it for yourself.