更改文件扩展名

Dob*_*obz 4 rename

在一个文件夹中,我有一个 .run 文件,我正在尝试将扩展名更改为 .clu。问题是我试过了

rename 's/.run$/.clu/' *.run
Run Code Online (Sandbox Code Playgroud)

但这对文件绝对没有任何影响。

注意:我不是要转换文件,只是要重命名扩展名。

Oli*_*Oli 6

我不知道你的问题是什么。您发布的内容有效:

$ mkdir test
$ touch test/test{01..10}.run
$ rename 's/\.run$/.clu/' test/*.run -vn
test/test01.run renamed as test/test01.clu
test/test02.run renamed as test/test02.clu
test/test03.run renamed as test/test03.clu
test/test04.run renamed as test/test04.clu
test/test05.run renamed as test/test05.clu
test/test06.run renamed as test/test06.clu
test/test07.run renamed as test/test07.clu
test/test08.run renamed as test/test08.clu
test/test09.run renamed as test/test09.clu
test/test10.run renamed as test/test10.clu
Run Code Online (Sandbox Code Playgroud)

-vn刚刚告诉我们,如果没有它,运行它会做什么。

我正在逃避点(否则它是一个正则表达式“任何东西”),但在这里真的没有区别。没有它它也能工作。


你真的有可能在跑步rename.ul吗?检查以确保您正在使用 Perl 重命名(采用我们正在使用的语法)dpkg -S $(readlink -f $(which rename))

  • perl: /usr/bin/prename 很好。
  • util-linux: /usr/bin/rename.ul不好。出于某种原因,您使用的重命名版本非常有限。发生了一件非常尴尬的事情。

目前,看看是否prename存在(你现在可以使用它),如果不存在,开始询问为什么 Perl 没有正确安装。建议您没有安装 Ubuntu。

或者,如果您对使用感到满意rename.ul,则以下内容应该有效:

rename.ul .run .clu *.run
Run Code Online (Sandbox Code Playgroud)

但是,这可能会咀嚼像一个文件test.run.hooray.runtest.clu.hooray.clu这显然不是很大。