@echo off
setlocal enabledelayedexpansion
set /p "folder=Please input folder: "
set /p "prefix=Please input prefix: "
set /a index=0
for /r "%folder%" %%i in (*.*) do (
rem echo 完整的路径: %%i
rem echo 无后缀路径: %%~dpni
rem echo 所在的目录: %%~dpi
rem echo 简略文件名: %%~ni
rem echo 文件后缀名: %%~xi
rem echo 完整文件名: %%~nxi
set /a index=index+1
if !index! lss 10 (
ren "%%i" "%prefix%_00!index!%%~xi"
) else if !index! lss 100 (
ren "%%i" "%prefix%_0!index!%%~xi"
) else (
ren "%%i" "%prefix%_!index!%%~xi"
)
)
pause
来源:oschina
链接:https://my.oschina.net/wutenghui/blog/3161220