排版输出
写了个没什么用的东西,对单双字节排版输出。
将文档以"指定字符"为分割符,排版输出。
效率不是很高,并且创建了两个临时文件。
:- @echo off&setlocal enabledelayedexpansion
- cd.>tmp.txt&cd.>tmp1.txt
- ::变量 f 为指定字符
- set "f= "
- for /f "delims=" %%a in (a.txt) do (
- call :loop "%%a"
- (echo.>>tmp.txt)
- )
- for /l %%l in (1 1 20) do set /a _%%l=0
- set "var=^(type tmp.txt^&echo.^)^|findstr /o .*"
- for /f "tokens=1* delims=:" %%a in ('%var%') do (
- if defined n (
- set /a m=%%a-2-n,flag+=1
- call set "lis=%%_!flag!%%"
- if !m! neq 0 (
- (>>tmp1.txt echo !m!:!name!.)
- if !m! geq !lis! set "_!flag!=!m!"
- ) else (
- (echo.#>>tmp1.txt)
- set /a flag=0
- ))
- set /a n=%%a&set "name=%%b"
- )
- set name=&set /a m=0
- for /f "tokens=1* delims=:" %%a in (tmp1.txt) do (
- set flag=&set /a m+=1
- call set "n=%%_!m!%%"
- set /a n=n-%%a
- for /l %%i in (1 1 !n!) do set "flag= !flag!"
- set "n=%%b"
- set "n=!n:~0,-1!!flag!"
- if not "%%a"=="#" (set "name=!name! %f% !n!") else (
- (echo !name:~3!)
- set name=&set /a m=0
- ) )
- del/q tmp.txt tmp1.txt
- echo.&pause&exit
- :loop
- for /f "tokens=1* delims=%f%" %%i in ("%~1") do (
- (>>tmp.txt echo %%i)
- if not "%%j"=="" call :loop "%%j"
- )
- goto :eof
复制代码
[ 本帖最后由 随风 于 2008-5-14 09:53 编辑 ] |