I stumbled across a handy Windows script file (WaRmZip) that is an all purpose utility for cleaning, compressing and/or moving outdated log files. For example, you may want to delete certain files older than X days. You can download this utility at WinAdmin’s web site: http://winadmin.forret.com/scripts/warmzip
One use of this utility is to delete older IIS log files. Go to C:\Windows\System32\LogFiles directory on your server, and take a look at the contents of each of the subfolders (W3SVC1, etc). You may be surprised to find hundreds of files in each of these subfolders. Using the WaRmZip utility, I can create a one line batch file to handle removing these log files, and then schedule this batch file to run weekly or monthly.
Here’s the one line batch command: “C:\WaRmZip17\WaRmZip.wsf” “C:\Windows\System32\LogFiles” /da:7 /r /q
In this example, the da:7 option says to delete files older than 7 days, the /r option says to process all sub folders, and the /q option says to run it quietly (non verbose). There are options to zip/compress these files instead, if that is your preference, or to move them to a different drive/folder.