回复 17# ouch1983 - @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-5" %%a in ('findstr /v /i "dwpi" test.txt') do (
- if /i "%%a"=="ap" (set flag=ap&set/a count=0)
- if /i "%%a"=="pn" (set flag=pn&set/a count=0)
- if "!flag!"=="ap" (
- if !count! equ 0 (set "strb=%%d") else set "strb=%%b"
- set/a "#!strb:~,4!+=1"
- if not defined "$!strb:~,4!" set "$!strb:~,4!=0"
- set/a count+=1
- )
- if "!flag!"=="pn" (
- if !count! equ 0 (set "strb=%%e") else set "strb=%%c"
- set/a "$!strb:~,4!+=1"
- if not defined "#!strb:~,4!" set "#!strb:~,4!=0"
- set/a count+=1
- )
- )
- 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
复制代码
|