Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 29 lines (25 sloc) 0.801 kB
fa62a31 @bronson Add a barely working pdfdir-copy command.
authored
1 #!/bin/bash
2 #
3 # pdfdir-copy
4 # Scott Bronson
5 # 16 May 2009
6 #
7 # Uses ghostscript to re-encode an entire directory of PDF files.
8 # This is the best way to remove encryption and recompress but it
9 # does take quite a lot of CPU time.
10 #
11 # We don't bomb out on empty files. We probably should.
12 # We do bomb out on random files.
13 # TODO: watch the output for 0-page files. Print them.
14 #
15 # usage: pdfdir-copy destination-dir
16 # copies all the pdfs in the current directory and all its subdirs
17 # to the specified destination-dir
18
19 output="$1"
20 mkdir -p "$output" || exit
21
22 find . -name "*.pdf" | while read i; do
23 echo "$i"
24 echo "$i" >> /tmp/errout
25 mkdir -p "$output/$(dirname "$i")"
26 gs -sDEVICE=pdfwrite -sOUTPUTFILE="$output/$i" -dBATCH -dNOPAUSE "$i" 2>>/tmp/errout || echo "$i" >> /tmp/badfiles
27 done
28
Something went wrong with that request. Please try again.