需要将一系列文件如out-M0.png, out-M1.png, out-M2.png, ... 重新命名为 color-0.png, color-1.png, color-2.png, ...
方法:获取各个文件名,然后将其中的字符串 out-M 替换为 color-
批处理代码:
@echo off&setlocal EnableDelayedExpansion
echo rename files begins...
set a=1
for /f "delims=" %%i in ('dir /b *.png') do (
set "str=%%~nxi"
set "replacestr=!str:out-M=color-!"
ren "%%i" "!replacestr!"
set /a a+=1
)
set /a a-=1
echo done. file counts:%a%.
pause