文件夹下所有图片批量在重命名1-9999

302 0

使用批处理重命名
重命名批处理文件所在路径以及子文件了里面所有的图片
在网上找的两个批处理修改的
1W张内,序号是1-9999;

代码

@echo off
setlocal enabledelayedexpansion
set count=10000
for /f "delims=" %%i in ('dir /b /s *.jpg,*.png,*.bmp,*.jpeg,*.gif') do call:Rename "%%~i"


for /f "delims=" %%a in ('dir /b /s 0*.jpg,0*.png,0*.bmp,0*.jpeg,0*.gif') do (
    set "fn=%%~na"
    ren "%%a" "!fn:~1!%%~xa"
)
for /f "delims=" %%a in ('dir /b /s 0*.jpg,0*.png,0*.bmp,0*.jpeg,0*.gif') do (
    set "fn=%%~na"
    ren "%%a" "!fn:~1!%%~xa"
)
for /f "delims=" %%a in ('dir /b /s 0*.jpg,0*.png,0*.bmp,0*.jpeg,0*.gif') do (
    set "fn=%%~na"
    ren "%%a" "!fn:~1!%%~xa"
)

pause
exit
 
:Rename
set /a count+=1

if /i "%~1"=="!count:~1!%~x1" goto :eof
if exist "!count:~1!%~x1" goto Rename
echo rename : %1 !count:~1!
ren "%~1" "!count:~1!%~x1"
goto :eof

序号是0001-9999
代码

@echo off
setlocal enabledelayedexpansion
set count=10000
for /f "delims=" %%i in ('dir /b /s *.jpg,*.png,*.bmp,*.jpeg,*.gif') do call:Rename "%%~i"

pause
exit
 
:Rename
set /a count+=1

if /i "%~1"=="!count:~1!%~x1" goto :eof
if exist "!count:~1!%~x1" goto Rename
echo rename : %1 !count:~1!
ren "%~1" "!count:~1!%~x1"
goto :eof

发表评论