用批处理或vbs 删除路径为:D:\BAK\备份\;下所有7天前的RAR文件。文件格式BAK_2015年09月08日21时30分30秒.rar
@echo off
::设置几天前
set n=7
>"%tmp%\t.vbs" echo;t=date()-%n%:y=right(year(t),4):m=right("0"^&month(t),2):d=right("0"^&day(t),2):wscript.echo y^&" "^&m^&" "^&d
for /f "tokens=1-3" %%a in ('cscript /nologo "%tmp%\t.vbs"') do set y=%%a&set m=%%b&set d=%%c
echo;%n%天前的日期为%y% %m% %d%
del "D:\BAK\备份\BAK_%y%年%m%月%d%日*.rar"
pause
::设置几天前
set n=7
>"%tmp%\t.vbs" echo;t=date()-%n%:y=right(year(t),4):m=right("0"^&month(t),2):d=right("0"^&day(t),2):wscript.echo y^&" "^&m^&" "^&d
for /f "tokens=1-3" %%a in ('cscript /nologo "%tmp%\t.vbs"') do set y=%%a&set m=%%b&set d=%%c
echo;%n%天前的日期为%y% %m% %d%
del "D:\BAK\备份\BAK_%y%年%m%月%d%日*.rar"
pause
测试前先备份源文件,及时采纳回答
温馨提示:答案为网友推荐,仅供参考