1-99999行的:- @echo off&setlocal enabledelayedexpansion
- set "str=一 二 三 四 五 六 七 八 九"&set "var=万千百十零"
- for %%i in (%str%) do set /a n+=1&set "_!n!=%%i"
- for /f "tokens=1* delims=:" %%i in ('findstr /n .* a.txt') do (
- set "a=%%i"&call :lp
- call,set "b=%%var:~-!m!%%"&set "m=0"
- set "a=%%i"
- call :loop %%i "%%j"
- )
- pause>nul&goto :eof
- :lp
- set "a=%a:~1%"&set /a m+=1
- if defined a goto lp
- goto :eof
- :loop
- if %1 lss 10 (
- call,set "string=%string%零%%_!a:~,1!%%"
- ) else (
- if %a:~,1% equ 0 (
- set "string=%string%零"
- ) else (
- if "%b:~,1%" neq "零" (
- call,set "string=%string%%%_!a:~,1!%%%b:~,1%"
- ) else (
- call,set "string=%string%%%_!a:~,1!%%"
- )
- )
- )
- set "b=%b:~1%"&set "a=%a:~1%"
- if defined a goto loop
- set "string=%string:零零零=零%"
- set "string=%string:零零=零%"
- if "%string:~-1%" equ "零" set "string=%string:~,-1%
- set "string=%string%行 "
- echo %string:~,9% %~2&set "string="
复制代码 测试文本a.txt由下面的代码生成- @echo off
- for /l %%i in (1,1,99999) do echo %%i>>a.txt
复制代码
|