Merge multiple jpg into single pdf in Linux

0 votes

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 conversion 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. Any help will be appreciated!


 

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
1,094 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
0 answers

How to convert a PDF into JPG with command line in Linux?

What are fast and reliable ways for ...READ MORE

Apr 14, 2022 in Linux Administration by Aditya
• 7,680 points
589 views
0 votes
1 answer

Merge multiple pdf files in one using terminal

Install a utility call pdfunite which is ...READ MORE

answered May 17, 2019 in Linux Administration by ajs3033
• 7,300 points
818 views
0 votes
1 answer

How to create nested directories with a single command in linux?

Try this command. mkdir -p /parent_dir/son_dir READ MORE

answered Oct 19, 2020 in Linux Administration by anonymous
• 19,610 points
2,224 views
–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3, 2019 in Linux Administration by Omkar
• 69,220 points
2,623 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Feb 1, 2019 in Linux Administration by Omkar
• 69,220 points
1,220 views
0 votes
1 answer

Finding pat of afile in linux

You can use readlink command: readlink -f filename.txt READ MORE

answered Mar 15, 2019 in Linux Administration by DareDev
• 6,890 points
964 views
0 votes
1 answer
0 votes
1 answer

Killing a Zombie Process

You can clean up a zombie process ...READ MORE

answered Jun 20, 2019 in Linux Administration by Upasana
• 8,620 points
994 views
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
1,210 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,307 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP