Delete Files Older Than N Days

Here’s how to delete files older than N days. We are using N = 7.


find /base-dir-to-delete -mtime +7 -type f -delete

You can test the command by removing “-delete”.

Windows 7

forfiles -p "c:\base-dir-to-delete" -s -m *.* /D -7 /C "cmd /c del @path"

You can test by replacing “del” with “echo”.

No Comments

Leave a Reply

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