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?


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

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


  • -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.

  • 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. – Moses Oct 20 '13 at 3:05
  • Working perfect. I use this for convert svg to png with: "find . -name '*.svg' -exec mogrify -format jpg {} +" – Indacochea Wachín Jan 24 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.