求个批处理命令,要求:将多个文件夹内的文件名下划线前的数字,按当前顺序修改为001,002,003

2024-11-29 03:41:02
推荐回答(1个)
回答1:

@echo off
for /f "tokens=1,2,3 delims=_." %%i in ('dir /a-d/b') do (
if not "%%k"=="" (
if exist "%%i.%%k" call :gm "%%i_%%j.%%k" "%%i.%%k"
if exist "%%i_%%j.%%k" ren "%%i_%%j.%%k" "%%i.%%k"
))
echo 更名完成!&pause>nul &exit
:gm
set n=0
:lp
set/a n+=1
if exist "%~n2(%n%)%~x2" goto lp
ren "%~1" "%~n2(%n%)%~x2"
goto :eof
System.out.println("Perimeter:"+perim);