回复 16# sinun
你手工修改注册表,把日期格式设置成 yyyy-M-d
把任务计划里面的脚本改成这样:- @echo off
- schtasks /create /tn DelData /tr "C:\DelData.bat" /sc daily /st 18:00:00 /ru system
-
- set SrcDir=C:\Data
- set DaysAgo=10
- >"%temp%\DstDate.vbs" echo LastDate=date()-%DaysAgo%
- >>"%temp%\DstDate.vbs" echo FmtDate=right(year(LastDate),4) ^& right("0" ^& month(LastDate),2) ^& right("0" ^& day(LastDate),2)
- >>"%temp%\DstDate.vbs" echo wscript.echo FmtDate
- for /f %%a in ('cscript /nologo "%temp%\DstDate.vbs"') do (
- set "DstDate=%%a"
- )
- set DstDate=%DstDate:~0,4%-%DstDate:~4,2%-%DstDate:~6,2%
- for /r "%SrcDir%" %%a in (*.*) do (
- echo "%%~ta" leq "%DstDate%">>C:\DelData.log
- if "%%~ta" leq "%DstDate%" (
- if exist "%%a" (
- del /f /q "%%a"
- )
- )
- )
复制代码
|