@echo off
setlocal enabledelayedexpansion
Rem -30是删除30天前的文件
echo wscript.echo dateadd("d",-30,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i&set m=%%j&set d=%%k
if %m% LSS 10 set m=0%m%
if %d% LSS 10 set d=0%d%
set riqi=%y%%m%%d%
set "mulu=d:\a"
for /f "eol= skip=4 tokens=1,4" %%a in ('dir /a-d /tw "%mulu%"') do (
set delrq=%%a
set delrq=!delrq:-=!
if "!delrq:~0,3!"=="200" (
if !delrq! lss %riqi% (
del /q "%mulu%\%%~nxb"
)
)
)
pause
里面的mulu=d:\a
是d:\a文件夹,你要哪个文件夹,自己设置哦..