[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off&setlocal enabledelayedexpansion
  2. cd.>c.txt
  3. echo %time%
  4. for %%a in (1 3 5 7 8 10 12) do set _%%a=31
  5. for %%a in (4 6 9 11) do set _%%a=30
  6. for /f "tokens=1-3 delims=- " %%a in ("%date%") do set/a "Year=%%a,Month=100%%b%%100,Day=100%%c%%100+1"
  7. for /f "delims=:" %%a in ('findstr /n /v $ "ab cd.txt"') do set /a "Line=%%a,Feb=28+^!(year%%4)"
  8. set "Monthes=1#31 2#%Feb% 3#31 4#30 5#31 6#30 7#31 8#31 9#30 10#31 11#30 12#31"
  9. for %%i in (%Monthes%) do for /f "tokens=1,2 delims=#" %%a in ("%%i") do if %%a leq %Month% set /a DayCount+=%%b
  10. for /f "tokens=%month%" %%a in ("%Monthes%") do for /f "tokens=1,2 delims=#" %%i in ("%%a") do set/a DayCount-=%%j-Day
  11. set /a LineTemp=Line-DayCount
  12. :loop
  13. set/a "LineTemp-=365+(^!(year%%4)&^!(^!(year%%100))|^!(year%%400)),Year-=1"
  14. if %LineTemp% geq 365 goto loop
  15. set/a "Year-=1,Month=12,Feb=28+^!(Year%%4)"
  16. :loop1
  17. if %LineTemp% gtr !_%Month%! (
  18.    for /f "tokens=%Month%" %%a in ("1#31 2#%Feb% 3#31 4#30 5#31 6#30 7#31 8#31 9#30 10#31 11#30 12#31") do (
  19.         for /f "tokens=1,2 delims=#" %%i in ("%%a") do set/a LineTemp-=%%j
  20.         set/a month-=1&goto loop1
  21. ))
  22. set /a Day=_%Month%-LineTemp
  23. for /f "usebackq delims=" %%a in ("ab cd.txt") do (
  24.       if !Month! lss 10 (set "Mon=0!Month!") else (set "Mon=!Month!")
  25.       if !Day! lss 10 (set "Da=0!Day!") else (set "Da=!Day!")
  26.       echo !Year!年!Mon!月!Da!日 %%a
  27.       set/a Day+=1
  28.       if !Day! GTR 28 CALL :MonitorMonthCount
  29. )>>c.txt
  30. echo %time%
  31. pause>nul&exit/b
  32. :MonitorMonthCount
  33. if %day% gtr !_%month%! set/a "day=1,month+=1"&echo.
  34. if !month! equ 13 set /a "month=1,year+=1,_2=28+(^!(year%%4)&^!(^!(year%%100)) | ^!(year%%400))"
复制代码
钻了一个空子,用findstr /n /v $ "ab cd.txt"来计算行数,当然最末行不能是空行。
心绪平和,眼藏静谧。

TOP

简直无敌了,测试随风兄的代码:
心绪平和,眼藏静谧。

TOP

我512M内存,1.6G双核CPU,机器配置也不怎么样。
测试最长的耗时时间正好是8秒。
这次测试结果:
心绪平和,眼藏静谧。

TOP

返回列表