33

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.

Merrythought
  • 355
  • 1
  • 3
  • 4

1 Answers1

56

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

arco444
  • 22,002
  • 12
  • 63
  • 67