@echo off & title 批量更名 By 依梦琴瑶
cd /d %~dp0
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /a-d/b *.img') do (
for /f "tokens=1,5,6 delims=_-" %%b in ('echo "%%~a"') do (
set "Str1=%%~b"
set "Str2=%%~c"
set "Str3=%%~d"
)
ren "%%~a" "!Str1!-!Str2:~-4!-!Str3:~-4!%%~xa" && (
echo "%%~a" 更名至 "!Str1!-!Str2:~-4!-!Str3:~-4!%%~xa"
) || (
echo "%%~a" 更名失败
)
)
pause
脚本放在那些img文件一起后执行。