image - Batch convert PNGs to individual PDFs while maintaining deep folder hierarchy in bash -


i've found solution claims 1 folder, have deep folder hierarchy of sheet music i'd batch convert png pdf. solutions like?

i run further problem down line, may complicate things. maybe should write script? (i'm total n00b fyi)

the "further problem" of sheet music spans more 1 page, if script can parse filenames include "1of2" , "2of2" turned single pdf, that'd neat.

what options here?

thank much.

updated answer

as alternative, following should faster (as conversions in parallel) , able handle larger numbers of files:

find . -name \*.png -print0 | parallel -0 convert {} {.}.pdf 

it uses gnu parallel readily available on linux/unix , can installed on osx homebrew using:

brew install parallel 

original answer (as accepted)

if have bash version 4 or better, can use extended globbing recurse directories , job simply:

first enable extended globbing with:

shopt -s globstar 

then recursively convert pngs pdfs:

mogrify -format pdf **/*.png 

Comments