让系统自己去判断生成的日期是否合法:- @echo off & chcp 936>nul
- (set bakDate=%date:~0,4%-%date:~5,2%-%date:~8,2%) & set /a n=1001
- :loop
- set /a "year=%random%%%10+2000, month=%random%%%12+1, day=%random%%%31+1"
- for /f %%e in ('echo. 2^>nul ^| date %year%-%month%-%day% ^| find "无法接受"') do if "%%e" neq "" goto loop
- (set /a n+=1) & echo %n:~1%:%date%
- if %n% leq 1100 goto loop
- date %bakDate%
- pause
复制代码
|