command line – Merge a set of enumerated.pdf information into one .pdf

on

|

views

and

comments


For easy concatenation of PDF information, the utility pdfunite is about so simple as it will get. It is without doubt one of the utilities that include the Poppler PDF rendering library and could be put in with brew set up poppler. Additionally it is included within the poppler-utils package deal in Debian and Ubuntu and the poppler package deal in ArchLinux and Fedora for those who’re utilizing Linux.

The utilization is

pdfunite file1.pdf file2.pdf file3.pdf mergedfile.pdf

To course of all information with the extension “pdf” within the present listing within the order of string numerical worth if there aren’t any whitespaces in any of the information:

pdfunite $(ls -v *.pdf) output.pdf

And if there are likely whitespaces within the filenames, it will get a little bit extra sophisticated, however this could work:

(ls -v *.pdf; echo output.pdf) | tr n  | xargs -0 pdfunite

Rationalization:

  • ls invokes the ls out of your $PATH ignoring any aliases. This can be essential in case you’ve an aliased ls that reveals further info (like particular characters to indicate sure permissions). You can even simply use an absolute path to the ls executable, like /usr/bin/ls.
  • ls -v kinds the information in keeping with (model) numbers inside textual content
  • tr n replaces newlines with NULLs after every file
  • xargs -0 tells xargs to make use of the NULL character to separate arguments

As you may see, correct dealing with of issues like whitespace (and different particular characters) when piping instructions within the shell can get a little bit sophisticated. If you would like to learn extra, I like to recommend David Wheeler’s complete article.

Share this
Tags

Must-read

Nvidia CEO reveals new ‘reasoning’ AI tech for self-driving vehicles | Nvidia

The billionaire boss of the chipmaker Nvidia, Jensen Huang, has unveiled new AI know-how that he says will assist self-driving vehicles assume like...

Tesla publishes analyst forecasts suggesting gross sales set to fall | Tesla

Tesla has taken the weird step of publishing gross sales forecasts that recommend 2025 deliveries might be decrease than anticipated and future years’...

5 tech tendencies we’ll be watching in 2026 | Expertise

Hi there, and welcome to TechScape. I’m your host, Blake Montgomery, wishing you a cheerful New Yr’s Eve full of cheer, champagne and...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here