Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 33 lines (27 sloc) 0.827 kb
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
1 #!/bin/bash
2 #
3 # pdfdir-copy
4 # Scott Bronson
5 # 16 May 2009
6 #
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
7 # usage: pdfdir-copy src-dir destination-dir
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
8 #
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
9 # Uses ghostscript to re-encode an entire directory hierarchy of PDF files.
10 # This is the best way to remove encryption and recompress but it does take
11 # considerable CPU time.
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
12 #
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
13 # TODO: We don't bomb out on empty files. We probably should.
14 # TODO: We show ugly ghostscript output and no progress info. Ugh.
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
15
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
16 srcdir="$1"
17 dstdir="$2"
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
18
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
19 if [ -z "$srcdir" ] || [ -z "$dstdir" ]; then
20 echo "usage: $(basename "$0") src-dir destination-dir"
21 exit
22 fi
23
24 mkdir -p "$dstdir" || exit
25
26 find $srcdir -name "*.pdf" | while read i; do
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
27 echo "$i"
28 echo "$i" >> /tmp/errout
62a675ed »
2009-03-26 Make the pdfdir-copy command work more like cp
29 mkdir -p "$dstdir/$(dirname "$i")"
30 gs -sDEVICE=pdfwrite -sOUTPUTFILE="$dstdir/$i" -dBATCH -dNOPAUSE "$i" 2>>/tmp/errout || echo "$i" >> /tmp/badfiles
fa62a316 »
2009-03-26 Add a barely working pdfdir-copy command.
31 done
32
Something went wrong with that request. Please try again.