做一个bat,检测本目录中,当天和昨天的rar文件是否已存在
发布网友
发布时间:2022-05-17 07:43
我来回答
共1个回答
热心网友
时间:2023-10-13 11:40
:On Error Resume Next
:Sub bat
echo off
echo '>nul & title 删除前天以及以前的 Rar 文件 By 依梦琴瑶
echo '>nul & cls & for /f "delims=" %%a in ('cscript /nologo -e:vbs "%~f0"') do set yst=%%a
echo '>nul & for /f "tokens=1-5* delims=_" %%a in ('dir /a-d /b *.rar') do (if %%~b%%~c%%~d lss %yst% del "%%~a_%%~b_%%~c_%%~d_%%~e" >NUL 2>NUL & echo 已成功删除 %%~a_%%~b_%%~c_%%~d_%%~e)
echo '>nul & echo 请按任意键退出 & pause>NUL
Exit Sub
End Sub
Wscript.Echo DatePart("yyyy",DateAdd("d",-1,date)) & Right("0" & DatePart("m",DateAdd("d",-1,date)), 2) & Right("0" & DatePart("d",DateAdd("d",-1,date)),2)
运行效果图: