:@echo off : KillOldLogs - written 3-18-05 Daryl Sirota (dsirota@syssrc.com) : Set the Age variable to the # of months of logs you want to keep : Then edit the delete command(s) below to purge any logs you have : Schedule this script to run daily - it will only purge the logs dated : exactly %age% months ago. set age=3 set day=%DATE:~7,2% set month=%DATE:~4,2% if %month% lss 10 set /a month= 0x%month% set year=%DATE:~10,4% set kyear=%year% set kday=%day% set /a Kmonth=%month% - %age% if %kmonth% lss 1 set /a kyear=%kyear% -1 if %kmonth% lss 1 set /a kmonth=%kmonth% + 12 set /a kyear2=%kyear% - 2000 if %kyear2% lss 10 set kyear2=0%kyear2% if %kmonth% lss 10 set kmonth=0%kmonth% echo Kill from %kmonth%/%kday%/%kyear% back (or %kyear2%) echo on del D:\logs\badmail\*.* /q del d:\logs\smtpsvc1\ex%kyear2%%kmonth%%kday%.log del \\eaexchangefe\logs$\w3svc1\ex%kyear2%%kmonth%%kday%.log del \\eaexchangefe\logs$\syslog\%kyear%-%kmonth%-%kday%.txt