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?

Regmi
  • 855

1 Answers1

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.