Delete files older than data using a batch file

Forfiles -p c:ackup -s -m *.* -d -5 -c “cmd /c del /q @path”

This will delete all files in my backup directory older than 5 days. To test it first, use this:

Forfiles -p c:ackup -s -m *.* -d -5 -c “Cmd /C Echo 0x22@Path@File0x22”

Workarounds for XP users might be;
http://windowsitpro.com/article/articleid/71600/jsi-tip-0274—delete-files-older-than-xx-days.html (but this require additional software to be ‘installed’).

Hmm the below seem to be some unix variant, but maybe something similar is possible in Windows.

http://lifehacker.com/software/command-line/cli-fun–delete-files-older-than-x-days-239124.php (seem cool)
find /path/to/files* -mtime +5 -exec rm {} ;
http://lifehacker.com/software/geek-to-live/geek-to-live-hard-drive-janitor-133190.php (the deluxe edition)

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *