Forfiles - Cleaning archives from old copies

Cleaning archives from old backups, etc. can be done using the standard forfiles utility. For automation, it is better to set the call in the task scheduler.

forfiles /p "C:\my_arch\" /m *.* /s /d -10 /c "cmd /c del @path /q"

/p - path to directory
/m - search mask, instead of any files, you can specify a specific extension, for example *.db
/s - process subdirectories
/d -10 - delete files with modification date older than 10 days
/q - quiet mode, without confirmation of actions

The utility is present in the system since Windows 7

Author: admin