日期:2014-05-17 浏览次数:20764 次
@echo off rem 假设要删除C盘test文件夹里面的十天前的文件 set TarDir=C:\test >"%tmp%\MyDel.vbs" echo dt=date()-10 >>"%tmp%\MyDel.vbs" echo s=right(year(dt),4) ^& right("0" ^& month(dt),2) ^& right("0" ^& day(dt),2) >>"%tmp%\MyDel.vbs" echo wscript.echo s for /f %%a in ('cscript /nologo %tmp%\MyDel.vbs') do @set DateFlag=%%a setlocal enabledelayedexpansion for %%i in (C:\test\*.*) do ( set t=%%~ti set FileDate=!t:~6,4!!t:~0,2!!t:~3,2! if !FileDate! lss %DateFlag% del /f "%%i" ) endlocal del "%tmp%\MyDel.vbs"