Converting multiple image files from JPEG to PDF format
In bash:
for f in *.jpg; do
convert ./"$f" ./"${f%.jpg}.pdf"
done
You can use the mogrify
command for this. Normally, it modifies files in-place, but when converting formats, it writes a new file (just changing the extension to match the new format). Thus:
mogrify -format pdf -- *.jpg
(Like enzotib's ./*.jpg
, the --
prevents any strange filenames from being interpreted as switches. Most commands recognize --
to mean "stop looking for options at this point".)
faster but unusual syntax:
parallel convert '{} {.}.pdf' ::: *.jpg
Runs in parallel (using https://www.gnu.org/software/parallel/). I haven't noticed any multi-threading in convert
yet, which would limit the effective parallelization. If that is your concern, see in the comment below for a method to ensure no multi-threading occurs.