Skip to content

Instantly share code, notes, and snippets.

@vphill
Created April 24, 2014 03:02
Show Gist options
  • Save vphill/11240008 to your computer and use it in GitHub Desktop.
Save vphill/11240008 to your computer and use it in GitHub Desktop.
Bash script used to created pdf files for the Texas State Documents Scanning process
for i in *
do
echo "creating pdfs"
find "$i" -maxdepth 1 -name "*.jpg" | xargs -i -n 1 -P 6 convert -density 200x200 -compress jpeg -quality 80 "{}" "{}".pdf
echo "compressing pdfs"
find "$i" -maxdepth 1 -name "*.jpg.pdf" | xargs -i -n 1 -P 5 gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile={}_out.pdf {}
cd "$i"
echo "concatinating pdfs"
pdftk *_out.pdf cat output temp.pdf
echo "linerizing pdf"
qpdf --linearize temp.pdf $i.pdf
rm *.jpg.pdf
rm *_out.pdf
rm temp.pdf
mkdir 01_jpg
mv *.jpg 01_jpg
mkdir 02_pdf
mv "$i".pdf 02_pdf
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment