Page 1 of 1

Using convert or mogrify - recursive sub-directories

Posted: 2014-07-04T14:14:54-07:00
by mc2028
I have a stash of *.tif files that need to be converted to *.pdf's, but they're unfortunately in a complex tree of directories and subdirectories (some as deep as 5-6). I've tried using find in conjunction with mogrify but without luck:

find ./ -name "*.tif" -exec mogrify -format pdf *.tif {} \;

I keep getting "find: No match" When I only use "find ./ -name "*.tif," everything is just fine (it lists all the files). So I'm not sure what's going on. I've been able to use find with other commands but never with mogrify or convert.

Any help greatly appreciated.

Re: Using convert or mogrify - recursive sub-directories

Posted: 2014-07-04T16:03:44-07:00
by fmw42
Neither one can be use that way as I understand it. Both do different things. mogrify can deal with only one folder at a time. convert cannot use wildcards for both input and output. However, you can write a script loop over each image in any directory to process with convert (or mogrify). But that is OS dependent. It appears you are on Unix.This has been discussed many time on this forum, so search the forum for "recursive".

Here are a few results of such search:
viewtopic.php?f=1&t=23424&p=98519&hilit ... ive#p98555
viewtopic.php?f=1&t=23424&p=98519&hilit ... ive#p98565
viewtopic.php?f=1&t=23424&p=98519&hilit ... ive#p98595
viewtopic.php?f=1&t=23424&p=98519&hilit ... ive#p98600
viewtopic.php?f=1&t=23424&p=98519&hilit ... ive#p98622
viewtopic.php?f=1&t=17774&p=67250&hilit ... ive#p67250


see mogrify and alternates to process multiple directories at:
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics/#mogrify_not

Re: Using convert or mogrify - recursive sub-directories

Posted: 2018-06-16T11:10:04-07:00
by Gus
In my case, I have achieved the goal with the following instruction in a CMD window in the root folder:

Code: Select all

FOR /R %f IN (*.jpg) DO mogrify -verbose -quality 96 "%f"
My goal was to reduce the size of thousands of images organized in hundreds of folders (I added -verbose to follow the process) by reducing JPEG quality a little bit.

It worked! :D