本帖最后由 pcl_test 于 2015-2-25 22:59 编辑
回复 1# honghong33
假设有test.txt- @echo off
- setlocal enabledelayedexpansion
- set n=0
- for /f "tokens=1* delims=:" %%a in ('findstr /n .* "test.txt"') do (
- set "str=%%b"
- if !n! lss 2 if not "!str!" == "" (
- >>$ echo,!str!
- set n=0
- )
- if !n! gtr 1 if not "!str!" == "" (
- >>$ echo.
- >>$ echo,!str!
- set n=0
- )
- if not "!n!" == "0" if "!str!" == "" (
- set /a n+=1
- )
- if "!n!" == "0" if "!str!" == "" (
- set /a n+=1
- )
- )
- move $ "test.txt"
- pause
复制代码
|