@echo off set /p firststr="请输入文件名前缀:" set /p kuozhan="请输入文件扩展名:" set a=0 setlocal EnableDelayedExpansion dir /b .\*.%kuozhan% | find /c /v "" >> .\tmp.txt set /p c=<.\tmp.txt del /a /f /q .\tmp.txt for %%i in (*.%kuozhan%) do ( set /a a+=1 if !a! gtr %c% (goto aa) echo %firststr%!a! echo %%i ren "%%i" "%firststr%!a!.%kuozhan%" ) :aa pause