重命名多个文件 - linux / ubuntu [英] Rename multiple files - linux/ubuntu
问题描述
我需要从目录中的图像文件中删除_1331045422。例如,我的图像文件名称如下所示: message-16 -error_1331045422.png
我实际上运行了一个脚本,以这种方式重命名所有的图像文件。
我还有其他文件(具有正确名称的图像文件,具有正确名称的js文件和css等)
请帮助我重命名命令所有图像文件都带有_1331045422,而不影响其他图像。
编辑:
我不仅具有文件错误的.png文件。还有gifs和jpegs。
您可以使用rename命令:
重命名的/ _\d +(\ .. {1,3})/ $ 1 / g'*
如果您的扩展名长度超过三个字符的文件,您可以更改{}之间的范围。
请注意,在某些系统上,rename命令是有点不一样
看看这里:
https://superuser.com/questions/70217/is-there-a-linux-command-like-mv-but-with-regex
I need to remove the "_1331045422" from image files in my directory.
for eg., my image file name looks like: message-16-error_1331045422.png
I actually ran a script which rename all image files this way. Also I have other files (image files with correct names, js files and css etc. which have correct names)
Please help me with a command to rename all image files with the "_1331045422" , without affecting others.
EDIT: I not only have .png files with the wrong filename. There are gifs and jpegs too.
You can use rename command:
rename 's/_\d+(\..{1,3})/$1/g' *
You can change the range between {} if you have files with extension longer than three chars.
Be carefull that on some system the rename command is a bit different. Have a look here: https://superuser.com/questions/70217/is-there-a-linux-command-like-mv-but-with-regex
这篇关于重命名多个文件 - linux / ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!