本帖最后由 flashercs 于 2022-2-5 16:39 编辑
- @echo off
- setlocal EnableDelayedExpansion
- cd /d "%~dp0"
- @REM 统计数据
- set srcfile="data.txt"
- set dstfile="data2.txt"
- (
- for /f "usebackq tokens=1,2*" %%A in (%srcfile%) do (
- set f1=%%A
- if "!f1:单号=!"=="!f1!" (
- echo.%%A %%B %%C
- ) else (
- if not defined %%B (
- set %%B=1001
- ) else (
- set /a %%B+=1
- )
- echo.%%A %%B-!%%B:~-3! %%C
- )
- )
- )>%dstfile%
-
- endlocal
- pause
- exit /b
复制代码
|