通过如下批处理命令可实现批量更改文件名:

@echo 
set DIR="%cd%"
echo DIR=%DIR%
set /p ext=文件类型:
set /p find=要替换内容:
set /p replace=替换内容:
for /f "delims=" %%i in ('dir /b /a-d "*.%ext%"' ) do ( 

set str1=%%i 
setlocal EnableDelayedExpansion
set "str1=!str1:%find%=%replace%!"
ren "%%i" "!str1!"
endlocal
)
pause

因为ren命令第二个参数必须是文件名,第一个参数可以是相对路径也可以是绝对路径,所以,在循环文件的时候,务必加入/b (参数:将只显示文件名与扩展名),模式是绝对路径。

相关文章:

  • 2021-08-15
  • 2021-12-30
  • 2021-07-16
  • 2021-05-30
  • 2021-12-14
  • 2021-06-20
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2021-06-12
  • 2021-12-20
  • 2021-05-29
  • 2021-05-22
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案