1

我想将 *_PolishedChrome.jpg 中的特定图像名称重命名为 *-pch.jpg。我尝试了很多不同的方法,包括重命名 DOS 命令,但找不到正确的方法。这些文件位于我桌面上的一个文件夹中,它们都是 .jpg 图像。有多个文件带有图像名称的最后一部分。

示例:将 3-04012C_PolishedChrome.jpg 重命名为 3-04012C-pch.jpg

我会很感激任何帮助,谢谢!

4

1 回答 1

0

I think this will do what you are looking for (just place it in the same folder as the jpgs and run):

Remember to make a backup of your files before running this, as it does move files on the disk. It could be done with rename, but that is more effort, as I'd have to parse out the file name.

Also note that running this twice will re-rename your files, so it can only really be run once within a folder... that can be changed, but this is more of a starting point.

@echo off
setlocal ENABLEDELAYEDEXPANSION
for /r %%i in (*.jpg) do (
set str=%%i
set str=!str:_PolishedChrome.jpg=!-pch.jpg!!
move %%i !str!
)

DEBUG version - prints out a log.txt to see what went wrong.

@echo off 
setlocal ENABLEDELAYEDEXPANSION
for /r %%i in (*.jpg) do (
set str=%%i
set str=!str:_PolishedChrome.jpg=!-pch.jpg!!
move %%i !str!
@echo move %%i !str! >> log.txt
)
于 2013-07-15T17:34:36.130 回答