- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1,2 delims= " %%i in (a.txt) do (
- if "%%i"=="张三" set /a zs+=%%j && echo %%i %%j>>张三.txt
- if "%%i"=="李四" set /a ls+=%%j && echo %%i %%j>>李四.txt
- if "%%i"=="王五" set /a ww+=%%j && echo %%i %%j>>王五.txt
- if "%%i"=="赵六" set /a zl+=%%j && echo %%i %%j>>赵六.txt
- )
- echo 合计 !zs!>>张三.txt
- echo 合计 !ls!>>李四.txt
- echo 合计 !ww!>>王五.txt
- echo 合计 !zl!>>赵六.txt
- (for /f "delims=" %%i in (张三.txt 李四.txt 王五.txt 赵六.txt) do (
- set /a i+=1
- echo !i! %%i
- ))>b.txt
- del 张三.txt 李四.txt 王五.txt 赵六.txt
- start b.txt
复制代码
|