Convert images in multiple sub-folders

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Waffles
Posts: 3
Joined: 2013-09-04T01:18:38-07:00
Authentication code: 6789

Convert images in multiple sub-folders

Post by Waffles »

I'm hoping to be able to run the convert command on a parent folder that will have multiple sub-folders nested within it. The sub-folder names will change over time, as will the image filenames. The only thing that won't change will be the output folder. I know the convert command can run on a specific folder and convert all images within it, but if I want it to search through the existing folders, convert all of the images and place them into the output folder, what command do I need to use?

I've tried using find without much luck, and mogrify doesn't seem to do what I need either, so I'm not sure whether it's actually possible?

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert images in multiple sub-folders

Post by snibgo »

IM doesn't have a "do subdirectories" command, so you would handle that with a script, calling IM once per subdirectory, possibly recursively.
snibgo's IM pages: im.snibgo.com
Waffles
Posts: 3
Joined: 2013-09-04T01:18:38-07:00
Authentication code: 6789

Re: Convert images in multiple sub-folders

Post by Waffles »

Thanks - unfortunately as the directory names change regularly I don't think I can do that.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert images in multiple sub-folders

Post by snibgo »

A script wouldn't need to know the directory names in advance. It would loop through all the directories, whatever their names. How you do this will depend on your script language. For example, in Windows:

Code: Select all

for /D %%f in (*) do echo %%f
(If run from the console, don't double the "%".)
snibgo's IM pages: im.snibgo.com
Waffles
Posts: 3
Joined: 2013-09-04T01:18:38-07:00
Authentication code: 6789

Re: Convert images in multiple sub-folders

Post by Waffles »

Ah ok, makes sense - thanks a million :)
Post Reply