Delete Files Older Than N Days

  • Post author:
  • Post category:Tools

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

Linux

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”.