这样行不?- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (tx.txt) do (
- set n=0
- set "str=%%i"
- set "str=!str:|=■|!"
- if "!str:~,1!"=="■" set "str=!str:~1!"
- call:lp "!str!"
- for /l %%a in (1 1 !n!) do if "!str%%a!"=="" (echo str%%a: "")else echo str%%a: !str%%a!
- )
- pause&exit
- :lp
- for /f "tokens=1* delims=|" %%i in (%1) do (
- set/a n+=1
- set "str=%%i"
- set "str=!str:■=!"
- set "str!n!=!str!"
- if not "%%j"=="" call:lp "%%j"
- )
复制代码 不能处理空格- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (tx.txt) do (
- set n=0
- set "str=%%i"
- set "str=!str:|=| !"
- if "!str:~,1!"=="|" set "str=!str:~1!"
- for %%a in (!str!) do (
- set/a n+=1
- set "str=%%a"
- if "!str:|=!"=="" (set "str!n!=""")else set "str!n!=!str:|=!"
- )
- for /l %%a in (1 1 !n!) do for %%b in (!str%%a!) do echo str%%a: %%b
- )
- pause
复制代码
|