::文件批量命名并按xxx_000x排序
@echo off ::文件批量命名并按xxx_000x排序 setlocal enabledelayedexpansion color 0a set "lastName=x" set /A num=0 for /f %%i in ('dir /b /a /o:n "*.png"') do ( IF NOT "%%i"=="%~n0%~x0" ( for /f "tokens=1 delims=_" %%j in ("%%i") do ( IF NOT "!lastName!" == "%%j" ( set /A num=1; set lastName=%%j ) if !num! lss 1000 set "name=0!num!" if !num! lss 100 set "name=00!num!" if !num! lss 10 set "name=000!num!" echo "%%~i" "%%j_x!name!%%~xi" rename "%%~i" "%%j_x!name!%%~xi" set /A num+=3 ) ) ) :end @echo 已结束 pause