How to convert jpg files into png files with linux command? + Difficulty = Subfolders

67.3k views Asked by At

I want to convert several jpg files into png files. As far as I know, one can use this command

mogrify -format png *.*

I have one problem, I have a lot of subfolders. Let's say a is my main folder and b,c and d are subfolders. The images are in the subfolders.

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.

1

There are 1 answers

0
arco444 On BEST ANSWER

Assuming you're in folder a the following might work for you

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