批处理:BAT 删除系统日期前几天为名的文件夹

@echo off&setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=-:/ " %%a in ("%date%") do (set Y=%%a&set M=%%b&set D=%%c&if "!M:~0,1!"=="0" set M=!M:~1!
if "!D:~0,1!"=="0" set D=!D:~1!)
set/a D-=3&if !D! leq 0 (set/a M-=1&if !M!==0 set/a Y-=1,M=12
set/a "T=^!(M-2)","R=(^!(Y%%4)&^!^!(Y%%100))|^!(Y%%400)","C=^!(M-4)|^!(M-6)|^!(M-9)|^!(M-11)","D=T*(28+R)+C*30+(^!T&^!C)*31"+D)
set
M=0%M%&set D=0%D%
set mydate=%Y%%M:~-2%%D:~-2%
@echo %mydate%
rd %mydate% /s/q
set/a D-=4&if !D! leq 0 (set/a M-=1&if !M!==0 set/a Y-=1,M=12
set/a "T=^!(M-2)","R=(^!(Y%%4)&^!^!(Y%%100))|^!(Y%%400)","C=^!(M-4)|^!(M-6)|^!(M-9)|^!(M-11)","D=T*(28+R)+C*30+(^!T&^!C)*31"+D)
set
M=0%M%&set D=0%D%
set mydate=%Y%%M:~-2%%D:~-2%
@echo %mydate%
rd %mydate% /s/q
set/a D-=5&if !D! leq 0 (set/a M-=1&if !M!==0 set/a Y-=1,M=12
set/a "T=^!(M-2)","R=(^!(Y%%4)&^!^!(Y%%100))|^!(Y%%400)","C=^!(M-4)|^!(M-6)|^!(M-9)|^!(M-11)","D=T*(28+R)+C*30+(^!T&^!C)*31"+D)
set
M=0%M%&set D=0%D%
set mydate=%Y%%M:~-2%%D:~-2%
@echo %mydate%
rd %mydate% /s/q

批处理:BAT 删除系统日期前几天为名的文件夹

上一篇:Node项目通过cluster API充分利用多核CPU


下一篇:关于world wind 的地形切片加载顿卡现象的解决办法2