I used the following command to convert and merge all the jpg
files in a directory to a single pdf file.
convert *.jpg file.pdf
The files in the directory are numbered from 1.jpg
to 123.jpg
. The convertion went fine but after converting the pages were all mixed up. I wanted the pdf to have pages from 1.jpg
to 123.jpg
in the same order as they are named. I tried with the following command as well:
cd 1 FILES=$( find . -type f -name "*jpg" | cut -d/ -f 2) mkdir temp && cd temp for file in $FILES; do BASE=$(echo $file | sed 's/.jpg//g'); convert ../$BASE.jpg $BASE.pdf; done && pdftk *pdf cat output ../1.pdf && cd .. rm -rf temp
But still no luck. Operating platform Linux.
Simply visit the Acrobat Online website and upload the files you want to merge. Reorder the files however you like and then click Merge files. After that, just download the merged PDF. This will combine all the JPGs-turned-PDFs into a single PDF you can easily share or view.
Combine PDFs with the gs commandUse the -sDEVICE attribute to specify the output device or function. Use the -sOUTPUTFILE to specify the merged PDF file. Use the -dBATCH to specify the PDF files to combine in the order you want them to appear. The command above will output merged_file.
Open a browser in JPG free application web site and go to the Merger tool. Click inside the file drop area to upload JPG files or drag & drop a JPG files. Click the 'MERGE' button to start merging files. Instantly download, view or send merged file as an email.
Or just read the ls
manual and see :
-v natural sort of (version) numbers within text
So, doing what we need in single command.
convert `ls -v *.jpg` foobar.pdf
Have fun ;) F.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With