Convert multiple images into single PDF

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Convert multiple images into single PDF Wed Mar 10, 2021 11:51 am • by mendel
Perhaps, I am missing something obvious, but I'm having so much trouble doing this. I have a folder with multiple images into it that I want to process into a *single* PDF (NOT each image ending up its own PDF).

In the past I have done this manually with a shell script:

Code: Select all
img2pdf --fit shrink --output out.pdf $(ls *.{jpg,png}|sort -V)


I don't care to necessarily use this, and could just as well use an automator workflow or something else. I just seem to be having trouble getting Hazel to work on *all* the images at once and to process them into a single PDF. Is there any way to do this?
mendel
 
Posts: 5
Joined: Fri Aug 28, 2015 3:13 pm

Re: Convert multiple images into single PDF Thu Mar 11, 2021 9:47 am • by Mr_Noodle
Rules operate on the item matched. While you can't have a rule match multiple files at once, you can have Hazel match a folder. If you can isolate the files to a folder, you can then have a rule match that folder, where the script can then run on the contents.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Convert multiple images into single PDF Thu Mar 11, 2021 2:23 pm • by mendel
I've isolated the files to a folder using 'sort into subfolder' and created a new rule that isolates that folder. However when I try running the script on the folder the PDF comes out blank, which I presume means it's not actually running on the contents.

The two actions I have are 'Run rules on on Folder Contents' and then 'run shell script' with the above code pasted in. Is there something wrong with the actions? the script? Any ideas? Thanks for the help!
mendel
 
Posts: 5
Joined: Fri Aug 28, 2015 3:13 pm

Re: Convert multiple images into single PDF Fri Mar 12, 2021 10:14 am • by Mr_Noodle
Don't use "Run rules on folder contents" in this case. Also, the shell script itself needs to be tweaked to take into account the path to the directory, and not the files within is passed in.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron