如何使用linux命令将jpg文件转换为png文件?+ 难度 = 子文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20975025/
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
How to convert jpg files into png files with linux command? + Difficulty = Subfolders
提问by Merrythought
I want to convert several jpg files into png files. As far as I know, one can use this command
我想将几个 jpg 文件转换为 png 文件。据我所知,可以使用这个命令
mogrify -format png *.*
I have one problem, I have a lot of subfolders. Let's say ais my main folder and b,cand dare subfolders. The images are in the subfolders.
我有一个问题,我有很多子文件夹。假设a是我的主文件夹,b、c和d是子文件夹。图像位于子文件夹中。
How can I convert all images without having to open every folder manually?
如何转换所有图像而不必手动打开每个文件夹?
-> I would like to write a command that works, when I am in folder a, but works for all files in the subfolders.
-> 我想编写一个在文件夹a中有效的命令,但对子文件夹中的所有文件都有效。
采纳答案by arco444
Assuming you're in folder a the following might work for you
假设您在文件夹 a 中,以下内容可能对您有用
find . -name "*.jpg" -exec mogrify -format png {} \;
You can use the find command to get all the jpg files in all the subfolders and pass your command as an argument to find
您可以使用 find 命令获取所有子文件夹中的所有 jpg 文件,并将您的命令作为参数传递给 find