本帖最后由 pcl_test 于 2015-4-15 17:13 编辑
- @echo off
- setlocal enabledelayedexpansion
- set "file=测试.txt"
- (set /p first=<"%file%"
- if "!first:~,1!" equ "-" (echo,!first! [1]) else (set/a r=t=0)
- for /f "tokens=1* delims=:" %%a in ('more +1 "%file%" ^|findstr /n .*') do (
- set str=%%b
- set n=%%a
- if "!str:~,1!" neq "-" (
- set/a r=t=0
- ) else (
- if !r! == 0 if !t! == 0 (set/a n+=1 &echo,%%b [!n!] &set t=1)
- )))>"结果.txt"
- pause
复制代码
|