The Computer Oracle

Batch run mogrify including subdirectories

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Realization

--

Chapters
00:00 Batch Run Mogrify Including Subdirectories
00:34 Accepted Answer Score 23
01:03 Thank you

--

Full question
https://superuser.com/questions/662544/b...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #commandline #find #exec

#avk47



ACCEPTED ANSWER

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