17

The command mogrify -format jpg *.NEF when run in a directory converts all *.NEF files to JPEGs. What I want to do is to be able to run mogrify in *.NEF files inside subdirectories as well using one command. I am trying to run something like:

find . -type d exec mogrify -format jpg *.NEF \;

and of course it is not working. Can someone suggest the proper command?

1 Answer 1

23

It looks like mogrify from ImageMagick 6.9.9.19 writes the result in the same directory as the input file, so you can use this command:

find . -name '*.NEF' -exec mogrify -format jpg {} +

Explanation:

  • -name '*.NEF' finds all *.NEF files; use -iname if you want the search to be case insensitive.

  • -exec ... {} + executes the command on all the matching files. An alternative would be to combine find with xargs.

2
  • Just a tip, you may want to expand on this a little as it was marked as low quality. Consider explaining what the command does in detail.
    – user201262
    Oct 20, 2013 at 3:05
  • Working perfect. I use this for convert svg to png with: "find . -name '*.svg' -exec mogrify -format jpg {} +" Jan 24, 2019 at 23:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .