- @echo off&setlocal enabledelayedexpansion
- ::因论坛无法处理tab跳格,
- ::测试时将代码中的 set "tab=#" 中的#号改为tab键即可。。
- ::注意事项:
- ::需处理的号码出现 多少号至多少号时
- ::如 160-162 这种情况下“-”号左右的数字位数必须是一样的
- :: 象 198-1234 这样的就会出错。
-
- set "wj1=a.txt"
- set "wj2=b.txt"
-
- set "tab=#"
-
- if "%tab%"=="#" (
- echo.&echo 请先将代码中的 set "tab=#" 中的#号改为tab键
- echo.&pause>nul&exit
- )
-
- set t=%time%
- echo.1>nul 3>"%wj2%"
- set /p var=<"a.txt"
- for /l %%a in (1 1 3) do set "var=!var:*%tab%=!"
- set "var=!var:%tab%= !"
- for /f "usebackq skip=1 delims=" %%i in ("%wj1%") do (
- for /f "tokens=1-3* delims=%tab%" %%a in ("%%i") do (
- set "sen=%%a"
- set "cen=%%b"
- set "quhao=%%c"
- )
- set str=%%i
- for /l %%a in (1 1 3) do set "str=!str:*%tab%=!"
- for %%z in (%var%) do (
- if not "!str:~0,1!"=="%tab%" (
- for /f "tokens=1 delims=%tab%" %%E in ("!str!") do (
- for %%f in (%%E) do (
- set "num=%%f"
- set "num2=!num:-=!"
- if "!num2!"=="!num!" (set x=1!num! 1 1!num!) else (
- set "x=1!num:-= 1 1!"
- )
- for /l %%L in (!x!) do (
- set num3=%%L&set "num3=!num3:~1!"
- echo %%z!num3! !sen! !cen! !quhao!
- ))))
- set "str=!str:*%tab%=!"
- ))
-
- echo.1>nul 4>con
- echo %t%
- echo %time%
- call :time0 "%t%" "%time%" ok
- echo %ok%
- pause
- start "" notepad "%wj2%"
- exit
-
- :time0 计算批处理运行时间 (封装)
- @echo off&setlocal&set /a n=0&rem code 随风 @bbs.bathome.net
- for /f "tokens=1-8 delims=.: " %%a in ("%~1:%~2") do (
- set /a n+=10%%a%%100*360000+10%%b%%100*6000+10%%c%%100*100+10%%d%%100
- set /a n-=10%%e%%100*360000+10%%f%%100*6000+10%%g%%100*100+10%%h%%100)
- set /a s=n/360000,n=n%%360000,f=n/6000,n=n%%6000,m=n/100,n=n%%100
- set "ok=%s% 小时 %f% 分钟 %m% 秒 %n% 毫秒"
- endlocal&set "%~3=%ok:-=%"&goto :EOF
复制代码
[ 本帖最后由 随风 于 2009-2-14 05:12 编辑 ] |