怎么编写一个以时间段删除某个文件下面文件夹的bat脚本

如题所述

@echo off
regedit /e "%temp%\bak.reg" "HKEY_CURRENT_USER\Control Panel\International"
::::统一格式化系统日期格式Win2000以上系统通用
>aDate.reg echo REGEDIT4
>>aDate.reg echo.
>>aDate.reg echo [HKEY_CURRENT_USER\Control Panel\International]
>>aDate.reg echo "sShortDate"="yyyy-MM-dd"
>>aDate.reg echo "sDate"="-"
>>aDate.reg echo "sTimeFormat"="HH:mm:ss"
regedit /s aDate.reg&del aDate.reg
>tmp.vbs echo Wscript.echo FormatDateTime(DateAdd("d", -700 ,Date),2)
for /f "delims=" %%i in ('cscript.exe //nologo tmp.vbs') do set tt=%%i&rem del tmp.vbs
::::还原系统原时间日期格式
regedit /s "%temp%\bak.reg"&del "%temp%\bak.reg"
echo 700天前是 %tt%
set "tt=%tt:/=%"
set "tt=%tt:-=%"
for %%z in ("cut","ent","digi") do call :slz %%z
echo 已完成
pause

:slz
if "%~1"=="" goto:eof
setlocal enabledelayedexpansion
for /f "delims=*" %%i in ('dir/s/a-d/b "D:\upload\%~1\*.*"') do (
for /f "delims= " %%a in ("%%~ti") do (
set "tti=%%a"
set "tti=!tti:/=!"
set "tti=!tti:-=!"
if !tti! lss %tt% del /f/a/q "%%i"&&echo 已删除 %%i
))
endlocal
goto:eof
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答