Score:0

Creating a pdf from folder with .jpg and .png using img2pdf and sort by newest on first page

nl flag

I want to create a pdf. The newest picture from the folder should be on the first page and oldest last page. I opened the terminal from the folder and used:

$ img2pdf *.jpg *.png --output combined.pdf

and it works great, but the oldest picture is on top. I just want to change the order of the images, the rest is perfect. They all have different names. And it's too many to rename all the pictures. ChatGPT was not helpful. Thank you in advance

Score:1
hr flag

Assuming that img2pdf processes the images in the order in which the positional arguments are expanded on the command line, I'd suggests switching to the z shell, whose glob qualifiers allow you to order the results by modification time:

$ zsh
% img2pdf *.(jpg|png)(.om) --output combined.pdf
stony56 avatar
nl flag
Omg you are a genius. Works very well thank you. Exactly what I wanted.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.