Posts by Tags

bash

Combining PDF Documents the Smarter Way

5 minute read

Published:

My previous post on combining multiple PDF files had an important caveat that things would end up in the wrong order if you had files with leading ID numbers that started at 1 and ended at 12, you’d end up with PDFs combined in the order 1, 10, 11, 12, 2, 3, …, 9. This is because the default sort in Bash is an alphabetic sort. This is just our standard alphabetic sort, but it gets tripped up when dealing with numbers. We can think of it as a type of ‘greedy’ algorithm because it sorts all inputs by the first character, before moving onto the second character within each subset. This behavior is fine (and desirable!) for words, but fails with numbers.

Combining PDF Documents

3 minute read

Published:

How many times have you found that your institution has access to a digital version of a book you need only to discover that it comes in 15 different PDF files? I use Zotero as my reference manager and it’s difficult to attach more than one file to an entry, so I’ve certaintly spent time in the past painstakingly combining every section of a book together before adding it to Zotero. I finally got tired of doing this by hand and wrote a short Bash script to automate this process. Now I can combine as many PDFs as I want with a single command!

references

Combining PDF Documents the Smarter Way

5 minute read

Published:

My previous post on combining multiple PDF files had an important caveat that things would end up in the wrong order if you had files with leading ID numbers that started at 1 and ended at 12, you’d end up with PDFs combined in the order 1, 10, 11, 12, 2, 3, …, 9. This is because the default sort in Bash is an alphabetic sort. This is just our standard alphabetic sort, but it gets tripped up when dealing with numbers. We can think of it as a type of ‘greedy’ algorithm because it sorts all inputs by the first character, before moving onto the second character within each subset. This behavior is fine (and desirable!) for words, but fails with numbers.

Combining PDF Documents

3 minute read

Published:

How many times have you found that your institution has access to a digital version of a book you need only to discover that it comes in 15 different PDF files? I use Zotero as my reference manager and it’s difficult to attach more than one file to an entry, so I’ve certaintly spent time in the past painstakingly combining every section of a book together before adding it to Zotero. I finally got tired of doing this by hand and wrote a short Bash script to automate this process. Now I can combine as many PDFs as I want with a single command!