本帖最后由 weichenxiehou 于 2012-6-1 20:00 编辑
- @echo off&setlocal enabledelayedexpansion
- set "tab= "
- for /f "delims==" %%a in ('set # 2^>nul') do set %%a=
- for /f "delims==" %%a in ('set $ 2^>nul') do set %%a=
- for /f "tokens=1,4,5" %%a in ('findstr /i "^ap ^pn" a.txt') do (
- set "stra=%%a"
- if /i "!stra:~,2!"=="ap" (set "strb=%%b"&set flag=ap) else (set
-
- "strb=%%c"&set flag=pn)
- if !flag!==ap (
- set/a "#!strb:~,4!+=1"
- if not defined "$!strb:~,4!" set "$!strb:~,4!=0"
- ) else (
- set/a $!strb:~,4!+=1
- if not defined "#!strb:~,4!" set "#!strb:~,4!=0"
- )
- )
- echo,%tab%PN%tab%AP>result.txt
- for /f "tokens=1,2 delims=#=" %%a in ('set #') do (
- echo,%%a%tab%!$%%a!%tab%%%b
- )>>result.txt
- start result.txt
复制代码
|