我正在尝试修改下面的代码,以递归方式重命名所有子目录中的所有文件类型,而不仅仅是单一类型:
@echo off
Setlocal enabledelayedexpansion
Set "Pattern=rename"
Set "Replace=reuse"
For %%# in ("C:\Folder\*.jpg") Do (
Set "File=%%~nx#"
Ren "%%#" "!File:%Pattern%=%Replace%!"
)
Pause&Exit
来源: How to rename file by replacing substring using batch in Windows
非常感谢任何帮助!
答案 0 :(得分:0)
尝试此修改,如果您发现结果符合预期,请在命令echo
Ren
@echo off
Setlocal enabledelayedexpansion
Set "Pattern=rename"
Set "Replace=reuse"
Set "MyFolder=%userprofile%\Desktop\test\*.*"
For %%# in ("%MyFolder%") Do (
Set "File=%%~nx#"
echo Ren "%%#" "!File:%Pattern%=%Replace%!"
)
Pause>nul & Exit