先发个粗糙的 感觉可以精简- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1* delims=:" %%i in ('findstr /n .* "1.txt"') do (
- if "%%j"=="" (
- for /f "tokens=1* delims=#" %%a in ("!str!") do (
- set .%%a=%%a#%%b&set str=
- ))
- if defined str (set str=!str!#%%j)else set str=%%j
- )
- for /f "tokens=1* delims=#" %%a in ("!str!") do set .%%a=%%a#%%b
- for /f "tokens=2 delims==" %%i in ('set .') do (
- set str=%%i
- set "str=!str:#=&echo.!"
- call:lp
- )
- pause&exit
- :lp
- echo %str%
- echo.
复制代码
再改就这样 没突破 下面继续吧
- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1* delims=:" %%i in ('findstr /n .* "1.txt"') do (
- if not "%%j"=="" (if defined str (set str=!str!#%%j)else set str=%%j)else set .!str!=ok&set str=
- )
- set .!str!=ok
- for /f "tokens=1 delims=.=" %%i in ('set .') do (
- set str=%%i
- set "str=!str:#=&echo.!"
- call:lp
- )
- pause&exit
- :lp
- echo %str%
- echo.
复制代码
[ 本帖最后由 terse 于 2008-8-31 20:39 编辑 ] |