Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 33 lines (27 sloc) 864 Bytes
# pdfdir-copy
# Scott Bronson
# 16 May 2009
# usage: pdfdir-copy src-dir destination-dir
# Uses ghostscript to re-encode an entire directory hierarchy of PDF files.
# This is the best way to remove encryption and recompress but it does take
# considerable CPU time.
# TODO: We don't bomb out on empty files. We probably should.
# TODO: We show ugly ghostscript output and no progress info. Ugh.
if [ -z "$srcdir" ] || [ -z "$dstdir" ]; then
echo "usage: $(basename "$0") src-dir destination-dir"
mkdir -p "$dstdir" || exit
find $srcdir -name "*.pdf" | while read i; do
echo "$i"
echo "$i" >> /tmp/errout
mkdir -p "$dstdir/$(dirname "$i")"
gs -sDEVICE=pdfwrite -sOUTPUTFILE="$dstdir/$i" -dBATCH -dNOPAUSE "$i" 2>>/tmp/errout || echo "$i" >> /tmp/badfiles
Jump to Line
Something went wrong with that request. Please try again.