重命名命令默认情况下不会覆盖,如何强制覆盖?

rename command is not overwriting as it should by default, how do I force overwrite?

我有一个 bash 脚本,它使用如下重命名命令:

sudo rename 's/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/Date---__Time-::/' 2019*

根据重命名手册页,命令应该默认覆盖,而不是使用 -o 标志覆盖。但是当我 运行 脚本时,它不会覆盖现有文件。但是,我收到一个错误,并且重复的文件没有得到脚本完成的任何其他处理。

Renaming Files

20190710220231.WAV not renamed: Date-2019-07-10__Time-22:02:31.WAV already exists 20190710220300.WAV not renamed: Date-2019-07-10__Time-22:03:00.WAV already exists 20190710220338.WAV not renamed: Date-2019-07-10__Time-22:03:38.WAV already exists 20190710220349.WAV not renamed: Date-2019-07-10__Time-22:03:49.WAV already exists

沮丧,我尝试只使用 mv 命令,但给了我一个不同的错误:

mv: target '20190710222433.WAV' is not a directory

所以我添加了一个 / 并得到了同样的错误。有什么建议吗?

您可以使用选项 -f 强制覆盖现有文件:

rename -f ...

人工重命名:

-f, --force
               Over write: allow existing files to be over-written.