Search images in subfolders and convert

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
keljnr
Posts: 11
Joined: 2018-10-16T03:29:47-07:00
Authentication code: 1152

Search images in subfolders and convert

Post by keljnr »

I have put together a simple script, which when used on the direct parent folder of the files, works fine:

Code: Select all

cd %~dpnx1
for %%a in (.) do set currentfolder=%%~na
magick "*jpg*" "*png*" "*tif*" "%currentfolder%.pdf"
It searches for jpg, png and tifs in a folder and converts to a pdf, renaming it as folders name.
Now how would I go about doing the same thing, but searching through various subfolders, instead of the direct parent?

Example:

Folder Top (<- search through this folder)
- Sub Folder A
- image_1.jpg
- image_2.jpg
- Sub Folder B
- image_3.tif
- image_4.tif
- Sub Folder C
- image_5.png
- image_6.png

So this should end up in three pdfs: Sub Folder A, Sub Folder B and Sub Folder C


I do hope that makes sense. Many thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Search images in subfolders and convert

Post by snibgo »

You should always say what version of IM, on what platform. You seem to be using Windows BAT scripts.

I suggest you look at, and experiment with, "for /R".
snibgo's IM pages: im.snibgo.com
Post Reply