回复 17# xiaoyuwxz
最初没有完全理解题意 ,现在知道了 。以下方法应该完全满足要求,只是稍为复杂了些- @echo off & setlocal enabledelayedexpansion
- call :GetDate y m d
- call :DateToDays %y% %m% %d% days1
- @for /f "tokens=1-3 delims=-" %%a in ('dir /b/ad') do (
- call :DateToDays %%a %%b %%c days2
- set/a days=days1-days2
- if !days! GEQ 30 rd /q /s "%%~fa-%%b-%%c"
- )
- endlocal
- exit/b
- :DateToDays %yy% %mm% %dd% days
- setlocal ENABLEEXTENSIONS
- set yy=%1&set mm=%2&set dd=%3
- if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
- set /a dd=100%dd%%%100,mm=100%mm%%%100
- set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
- set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
- endlocal&set %4=%j%&goto :EOF
- :GetDate yyyy mm dd
- setlocal ENABLEEXTENSIONS
- set "first="
- for /f "tokens=1-3 delims=.-/ " %%a in ('date/t') do (
- if not defined first set first=1&set yy=%%a&set mm=%%b&set dd=%%c)
- endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF
复制代码
|