@echo off echo *************************************************************************************** echo Get Current Time!! echo *************************************************************************************** chcp 936 set NOW_TIME_HH=%time:~0,2% if "%NOW_TIME_HH%" lss "10" (set NOW_TIME_HH=0%time:~1,1%) else (set NOW_TIME_HH=%time:~0,2%) set NOW_TIME=%date:~0,4%-%date:~5,2%-%date:~8,2%_%NOW_TIME_HH%-%time:~3,2%-%time:~6,2% echo Current Time:%NOW_TIME% :A :: ======删除目录文件夹及其子文件夹内后缀名为.bak 且 7天之前的文件。====== forfiles /p "D:\databack" /s /m * /d -50 /c "cmd /c del @path" >> D:\DBBak\deletefile.txt 2>&1 if not %errorlevel% == 0 (goto bak) :B :: ======删除目录文件夹及其子文件夹内后缀名为.diff 且 7天之前的文件。====== ::forfiles /p "D:\databack" /s /m *.diff /d -50 /c "cmd /c del @path" >> D:\DBBak\deletefile.txt 2>&1 ::if not %errorlevel% == 0 (goto diff) :C :: ======删除目录文件夹及其子文件夹内后缀名为.trn 且 7天之前的文件。====== ::forfiles /p "D:\databack" /s /m *.trn /d -50 /c "cmd /c del @path" >> D:\DBBak\deletefile.txt 2>&1 ::if not %errorlevel% == 0 (goto trn) else (goto success) :bak echo %NOW_TIME% bak cleanup failed >> d:\failed.log goto:B :diff echo %NOW_TIME% diff cleanup failed >> d:\failed.log goto:C :trn echo %NOW_TIME% trn cleanup failed >> d:\failed.log goto:failed :failed echo *************************************************************************************** >> G:\failed.log echo %NOW_TIME% clean backup failed >> d:\failed.log echo *************************************************************************************** >> G:\failed.log exit 55 :success echo *************************************************************************************** >> G:\success.log echo %NOW_TIME% clean backup success >> d:\success.log echo *************************************************************************************** >> G:\success.log exit 0