bash 查找大 *.jpg 并将其重命名为 *.jpeg
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5866243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
finding and renaming large *.jpg to *.jpeg
提问by Dan
I have a large and messy collection of file--hey who doesn't--some of these are large JPGs (large in this case is an arbitrary number, say 2.5MB) that I want to rename--I want to change the extension from *.jpgto *.jpeg.
我有一大堆杂乱的文件——嘿谁没有——其中一些是我想重命名的大 JPG(在这种情况下,大是一个任意数字,比如 2.5MB)——我想改变扩展从*.jpg到*.jpeg.
I'd love to do this with a shell script, I'm running BASH 3.2.39(1), and I have a feeling this is "simple" task with find, alas I find find's syntax difficult to remember and the man page impossible to read.
我很想用一个 shell 脚本来做这个,我正在运行BASH 3.2.39(1),我觉得这是一个“简单”的任务find,唉,我发现它的语法很难记住,手册页也无法阅读。
Any and all help with be most appreciated.
非常感谢任何和所有帮助。
回答by Erik Martino
Finding and renaming large files could be done like this:
查找和重命名大文件可以这样完成:
find . -size +2500k -exec rename -s .jpg .jpeg '{}' ';'
find . -size +2500k -exec rename -s .jpg .jpeg '{}' ';'
回答by gnur
What OS are you using? In most repositories there is an app called mmv which is perfect for these kinds of things..
你使用的是什么操作系统?在大多数存储库中有一个名为 mmv 的应用程序,它非常适合这些类型的事情。
usage:mmv \*.jpg \#1.jpeg
用法:mmv \*.jpg \#1.jpeg
回答by Peter
Install rename (standard tool in your linux installation or with homebrew for mac), then:
安装重命名(Linux 安装中的标准工具或 mac 自制软件),然后:
rename -s .jpg .jpeg *
or, if you have files in subdirectories too:
或者,如果您在子目录中也有文件:
rename -s .jpg .jpeg $(find . -name '*.jpg')
回答by Vijay
for i in *.jpg
do
new_name= $(echo $i|sed 's/.jpg/.jpeg/')
mv $i $new.name
done

