1 @echo off 2 ::删除指定路径下指定天数之前(以文件的最后修改日期为准)的文件。 3 ::本例需要Win2003/Vista/Win7系统自带的forfiles命令的支持 4 rem 指定待删除文件的存放路径 5 set SrcDir=D:ajaxtrainweb 6 rem 指定天数 7 set DaysAgo=0 8 rem 要删除的文件通配 9 set searchmast=*.html 10 set filename=D:ajaxtrainwebdeletefile.log 11 12 echo -------------------Delete Expired Log Files------------------------- >>%filename% 13 echo Start >>%filename% 14 echo (%date% %time%) >>%filename% 15 echo Delete the expired log files in %SrcDir%, Please wait... >>%filename% 16 forfiles /p %SrcDir% /s /m %searchmast% /d +%DaysAgo% /c "cmd /c echo @path >>%filename% && del /f /q /a @path " 17 echo End >>%filename% 18 echo (%date% %time%) >>%filename% 19 ::pause