0

This question already has an answer here:

I have a few hundred image files. This consist of files of multiple type like 1.png 2.jpg 3.png and so on. I want to create a PDF from these images without changing the order of pages. The number in the image name must be used to preserve the order of pages.

marked as duplicate by Parto, Byte Commander, Ravan, Eric Carvalho, hg8 Nov 28 '15 at 11:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Using imagemagick, you could use a script like that

TMP=`mktemp -d`
for img in `ls`; do
    convert "$img" "$TMP"/"$img".pdf
done

convert $TMP/*.pdf merged.pdf

EDIT: I saw now a similar response. The only thing that this script adds is merging all the files in only one pdf.

  • Actually I used pdfunite at the last line as convert is blurring the images – Sunny Nov 20 '15 at 12:19
2

You could create a bash script:

#!/bin/bash

for f in *.jpg; do
  convert ./"$f" ./"${f%.jpg}.pdf"
done

EDIT: Source - https://unix.stackexchange.com/questions/29869/converting-multiple-image-files-from-jpeg-to-pdf-format

  • OP said that there are multiple extensions like jpg and png, not only one. And you could just write that command in one line instead of creating a script file for it. – Byte Commander Nov 20 '15 at 11:28
  • I missed that...I'll have to pay closer attention, apparently – SlidingHorn Nov 20 '15 at 11:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.