Here is a little command that I came across when I was looking for a quick and easy way to delete some old log files from my system.
C:\>forfiles /?
FORFILES [/P pathname] [/M searchmask] [/S]
[/C command] [/D [+ | -] {MM/dd/yyyy | dd}]
Description:
Selects a file (or set of files) and executes a
command on that file. This is helpful for batch jobs.
As the command descriptions suggests, its great for using in a .bat file, so I put following line in a cleanLogs.bat file, and scheduled a task to run the batch job every weekend to clean up my system of old and unwanted logs.
forfiles /p E:\Logs\ /s /m *.log /d -60 /c “cmd /c del @path”
forfiles.exe is a tool that has existed in old res kits and has been moved to the standard installation of the newer Microsoft operating systems like Windows Vista and Windows 2003.