## 2010年11月17日星期三

### 批处理实现一行内容分行输出的代码

a.txt：

aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九

abcdefghi
ABCDEFGHI
123456789

523066680：

@echo off
setlocal enabledelayedexpansion
set a=-1
for /f "tokens=*" %%a in ('type 1.x') do set hang=%%a
:a
set /a a+=1
set /a b=%a%
:b
set hang%a%=!hang%a%!!hang:~%b%,1!
set /a b=%b%+4
if not "!hang:~%b%,1!"=="" goto :b
echo,!hang%a%!
if %a% leq 2 goto :a
pause

@echo off&setlocal EnableDelayedExpansion
set "str=aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九"
for /l %%a in (0 1 35) do (
set /a n+=1
call set .!n!=%%.!n!%%!str:~%%a,1!
set /a n=n%%4
)
for /f "tokens=2 delims==" %%a in ('set .') do echo %%a
pause>nul

terse：

@echo off&setlocal EnableDelayedExpansion
set "str=aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九"
for /l %%i in (0 1 3) do for /l %%j in (%%i 4 35) do set %%i=!%%i!!str:~%%j,1!
for /l %%i in (0 1 3) do echo !%%i!
pause>nul

netbenton：

@echo off&setlocal ENABLEDELAYEDEXPANSION
set "x=aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九"
for /l %%a in (0,1,3) do ((for /l %%b in (%%a,4,35) do set/p=!x:~%%b,1!< nul)&echo.) pause