Initial commit
This commit is contained in:
29
split.sh
Executable file
29
split.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
pages="$1"
|
||||
infile="$2"
|
||||
outdir="$3"
|
||||
|
||||
if [ ! -f "$infile" ]; then
|
||||
echo "$infile does not exist" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$outdir" -a ! -d "$outdir" ]; then
|
||||
echo "$outdir must be a directory or not exist at all" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$outdir"
|
||||
|
||||
if [ "$((${pages}%2))" -ne 0 ]; then
|
||||
echo "The number of pages ($pages) must be even" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
i=0
|
||||
while [ "$i" -lt "$pages" ]; do
|
||||
paperjam "select { $((${i}+1)) $((${i}+2)) }" "$infile" "$outdir/$(printf '%0*d' ${#pages} $i).pdf"
|
||||
i="$((${i}+2))"
|
||||
done
|
||||
Reference in New Issue
Block a user