本帖最后由 慕夜蓝化 于 2015-1-25 13:55 编辑
- @echo off&setlocal enabledelayedexpansion
- For /f "tokens=1,2 delims==" %%i in (a.txt) do (
- set "str=%%i"&set "n=%%j"
- if "!str!"=="!sri!" (
- set/a _!str:~,2!+=!n!&set "n=0"
- ) else (
- set/a _!str:~,2!+=!n!
- )
- set "sri=%%i"
- )
- (For /f "tokens=1-2 delims=_=" %%i in ('set _') do (
- for /f "tokens=1-2 delims==" %%a in ('findstr /i /b "%%i" "a.txt"') do (
- set/a n+=1
- if !n! equ 1 echo,%%a=%%j
- )
- set "n="
- )) >b.txt
- pause
复制代码 感觉太偏了。总是把问题想的太复杂。 |