Content

Delete Files Older Than Date Using Batch Files

13 Apr

+ 0

This problem has nagged at me for years.  Here is a batch command to delete files on a Windows 2003 machine.

Forfiles -p c:\backup -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:\backup -s -m *.* -d -5 -c "Cmd /C Echo 0x22@Path\@File0x22"

This will print out each file that you will be deleting.

Now playing: Lamb Of God - Terror And Hubris In The House Of Frank Pollard

Comment

#

I reserve the right to delete and / or modify the comments that contain inappropriate language, spam or other behavior not appropriate in a civilized community. If your comment does not appear, it may be that akismet caught it.