1 @echo off2 :: Deletes a file that precedes a specified number of days under the specified path, whichever is the last modified date of the file. 3:: This example requires Win2003/Vista/support for the Win7 system's own forfiles command4 REM Specifies the storage path of the file to be deleted5 SetSrcdir=D:\ajaxtrain\web6 rem Specified days7 SetDaysago=08 rem To remove the file wildcard9 Setsearchmast=*. htmlTen SetFilename=D:\ajaxtrain\web\deletefile.log One AEcho-------------------Delete Expired Log Files------------------------->>%filename% -Echo Start >>%filename% -Echo (%date%%time%) >>%filename% theecho Delete the expired log filesinch%srcdir%, please wait ... >>%filename% -Forfiles/P%srcdir%/S/M%searchmast%/D +%daysago%/C "cmd/C echo @path >>%filename% && del/F/Q/A @path " -Echo End >>%filename% -Echo (%date%%time%) >>%filename% +::p ause
Deletes a file that precedes a specified number of days under the specified path, whichever is the last modified date of the file