按顶楼样本可这样,特点是最后4位都是后缀名的形式。(有规律)- @echo off
- for /f "delims=" %%a in (a.txt) do set /a .%%~xa+=1
- for /f "tokens=1,2 delims==." %%a in ('set .') do echo %%a = %%b
- pause
复制代码 若后面的4位没有规律,可用下面的方法。
:- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in (a.txt) do (
- set "var=%%a"
- set /a .!var:~-4!+=1
- )
- for /f "tokens=1,2 delims==." %%a in ('set .') do echo %%a = %%b
- pause
复制代码
|