稍微修改一下,楼上代码若中间空行中有空格的话则会连此行也算进去。- @echo off
- setlocal enabledelayedexpansion
- cd.>b.txt
- set n=0
- for /f "delims=" %%a in (a.txt) do (
- set "str=%%a"
- set str=!str: =!
- if defined str (
- set /a n+=1
- set /p=%%a <nul>>b.txt
- if "!n!"=="4" (
- set n=0
- echo.>>b.txt
- )
- )
- )
- pause
复制代码 对于生成的b.txt进行如下操作:- @echo off
- setlocal EnableDelayedExpansion
- cd.>b.xls
- for /f "delims=" %%i in (b.txt) do (
- set "str=%%i"
- set "str=!str: = !"
- set "str=!str: ={TAB} !"
- echo !str!
- echo !str!>>b.xls
- )
- pause
复制代码
{TAB}处按键盘上的TAB键
[ 本帖最后由 lhjoanna 于 2008-12-29 16:35 编辑 ] |