Tag Archives: shell scripting

Split PDF files easily using Ubuntu scripts

One of the fun parts of reinstalling an OS (yes, I think it is fun!), is to discover new software and new ways of doing things. As such, it works as a “digital shower”, getting rid of unnecessary stuff that has piled up.

Trying to also get rid of some physical mess, I am scanning some piles of paper documents. This leaves me with some large multi-page PDFs that I would like to split up easily. In the spirit of software carpentry I looked for a simple solution for splitting up a PDF file, and came across the command “burst” in the little terminal application pdftk. To use it on Ubuntu, you will first need to install it, using the terminal command:

sudo apt update && sudo apt install pdftk

Then this one-liner is all that is necessary to split a PDF file into a series of individual PDFs:

pdftk your-file.pdf burst

For convenience, I also made it into a small Ubuntu script:

This script can run by right-clicking on a file in the file manager:

And the end-result is a series of individual PDF files:

And then you can of course also combine the files again, either all PDFs:

pdftk *.pdf cat output newfile.pdf

or only the files you like:

pdftk file1.pdf file2.pdf cat output newfile.pdf