批处理指定删除5天前的文件夹
bat代码
@echo "删除指定5天前备份文件"
@set datetime=%date%
@set yy=%datetime:~0,4%
@set mm=%datetime:~5,2%
@set dd=%datetime:~8,2%
::md %yy%%mm%%dd%
::@echo wscript.echo dateadd("d",-1,date)>vbs.vbs
@FOR /F %%i in ('c:\windows\system32\cscript.exe /nologo "vbs.vbs"') do rd %%i /s /q
@set datetime=%date%
@set yy=%datetime:~0,4%
@set mm=%datetime:~5,2%
@set dd=%datetime:~8,2%
::md %yy%%mm%%dd%
::@echo wscript.echo dateadd("d",-1,date)>vbs.vbs
@FOR /F %%i in ('c:\windows\system32\cscript.exe /nologo "vbs.vbs"') do rd %%i /s /q
vbs.vbs
tmpdate = dateadd("d",-5,date)
targetdate=year(tmpdate)&"-"&fix(month(tmpdate)/10)&(month(tmpdate)-fix(month(tmpdate)/10)*10)&"-"&fix(day(tmpdate)/10)&(day(tmpdate)-fix(day(tmpdate)/10)*10)
wscript.echo targetdate
targetdate=year(tmpdate)&"-"&fix(month(tmpdate)/10)&(month(tmpdate)-fix(month(tmpdate)/10)*10)&"-"&fix(day(tmpdate)/10)&(day(tmpdate)-fix(day(tmpdate)/10)*10)
wscript.echo targetdate