0

我有很多文件要重命名(手动操作太多),通常我会使用 Automator 但问题是,我需要将所有其他文件与之前的文件调用相同,但使用一个2而不是1

这是我到目前为止的文件

xxx - 401a - yyy.zzz
xxx - 401b - yyy.zzz
xxx - 402a - yyy.zzz
xxx - 402b - yyy.zzz
xxx - 403a - yyy.zzz

依此类推,但我想将它们重命名为

xxx - 401-pt1.zzz
xxx - 401-pt2.zzz
xxx - 402-pt1.zzz
xxx - 402-pt2.zzz
xxx - 403-pt1.zzz

无论如何用自动机来做这个?问是因为我真的很少使用 Automator,这意味着我不完全是你所说的专家。

编辑:这就是我想要实现的目标:http ://wiki.plexapp.com/index.php/Media_Naming_and_Organization_Guide#Stacked_Episodes

4

1 回答 1

2

If you don't know anything about that tool than you won't mind using something else? How about a simple shell command?

Here is the same operation in Bash in increasing level of genericity. You probably don't care for the first two as it has hardcoded yyy's and zzz's but I did it to show you around the sed command a bit to understand the third one.

for file in * ; do mv "$file" "$(echo $file | sed 's/a - yyy/-pt1/g')"; mv "$file" "$(echo $file | sed 's/b - yyy/-pt2/g')"; done

for file in * ; do mv "$file" "$(echo $file | sed 's/a - .*.zzz/-pt1.zzz/g')"; mv "$file" "$(echo $file | sed 's/b - .*.zzz/-pt2.zzz/g')"; done

for file in * ; do mv "$file" "$(echo $file | sed -r 's/a - .*.([a-z]{3})/-pt1.\1/')"; mv "$file" "$(echo $file | sed -r 's/b - .*.([a-z]{3})/-pt2.\1/')"; done

There must be many other ways with other commands, of course. You'll get unimportant errors because the mv is done twice on the whole batch.

于 2013-06-20T19:44:37.310 回答