Skip to content

Commit 40b367a

Browse files
committed
Initial commit.
1 parent 6ecdfd9 commit 40b367a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
# splitappendix
22
A simple shellscript for splitting the PDF of a paper into the main body and an appendix.
3+
4+
This isn't exactly rocket science, but it's something I have to do frequently enough when submitting academic papers that I figured it's worth semi-automating. Hopefully you find it saves you a few minutes each time too!
5+
6+
## Installation
7+
8+
Simply clone the repo, move/rename the script to your somewhere on your `$PATH`, and make it executable. For example:
9+
10+
```bash
11+
git clone [email protected]:egrefen/splitappendix.git
12+
cd splitappendix
13+
chmod +x splitappendix.sh
14+
echo ln -s `pwd`/splitappendix.sh ~/.local/bin/splitapp
15+
```
16+
17+
## Usage
18+
19+
```bash
20+
splitapp path_to_paper.pdf first_page_of_appendix
21+
```
22+
23+
This assumes you've named the script `splitapp` and put it in your path.
24+
Once run, the files `submission.pdf` and `appendix.pdf` will be put in the same directory as the target paper.
25+
26+
## License
27+
28+
This project is released under the MIT License. See [LICENSE](./LICENSE) for details.

splitappendix.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
command -v qpdf >/dev/null 2>&1 || { echo >&2 'Dependency qpdf not found. Please install qpdf.'; exit 1; }
4+
command -v pdfinfo >/dev/null 2>&1 || { echo >&2 'Dependency pdfinfo not found. Please install pdfinfo.'; exit 1; }
5+
command -v awk >/dev/null 2>&1 || { echo >&2 'Dependency awk not found. How do you not have awk installed??'; exit 1; }
6+
7+
if [ $# -ne 2 ]
8+
then
9+
SCRIPT=$(basename "$0")
10+
echo >&2 "usage: $SCRIPT path_to_paper.pdf first_page_of_appendix"
11+
exit 1
12+
fi
13+
14+
cd "`dirname "${1}"`"
15+
16+
PAPER=`basename "${1}"`
17+
BEGINAPP=$2
18+
ENDMAIN=$((${BEGINAPP}-1))
19+
LASTPAGE=$(pdfinfo "$PAPER" | grep Pages | awk '{print $2}')
20+
21+
qpdf "${PAPER}" --pages . 1-${ENDMAIN} -- ./submission.pdf
22+
qpdf "${PAPER}" --pages . ${BEGINAPP}-${LASTPAGE} -- ./appendix.pdf

0 commit comments

Comments
 (0)