Created
December 13, 2016 14:59
-
-
Save giehlman/c281ad3d371cfdae033f15e9e68d964f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
#/pdf-bulk-merge.sh.sh <INPUT_PATTERN e.g. in_%d.pdf> <OUTPUT_PATTERN e.g. out_%d.pdf> <PAGES> <JOBS e.g. $(ls -la INPUT_PATTERN* | wc -l) | |
INPUT_PATTERN=$1 | |
OUTPUT_PATTERN=$2 | |
PAGES=$3 | |
JOBS=$4 | |
echo -e "Starting to work on\ninputPattern\t${INPUT_PATTERN}\npages\t${PAGES}\njobs\t${JOBS}" | |
_unite2() { | |
fileA=$1 | |
fileB=$2 | |
fileOut=$3 | |
echo -e "Merging files:\t${fileA}\t${fileB}\tout:\t${fileOut}" | |
qpdf ${fileA} -pages ${fileA} 1-1 ${fileB} 1-1 -- ${fileOut} | |
} | |
_split() { | |
echo "split" | |
} | |
for i in $(seq 1 $((PAGES)) $((JOBS)) ) | |
do | |
_unite2 $(echo ${INPUT_PATTERN} | sed "s/%d/$i/g") $(echo ${INPUT_PATTERN} | sed "s/%d/$((++i))/g") $(echo ${OUTPUT_PATTERN} | sed "s/%d/$i/g") | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment