forked from dmbaturin/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall2pdf.sh
More file actions
executable file
·31 lines (24 loc) · 762 Bytes
/
all2pdf.sh
File metadata and controls
executable file
·31 lines (24 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# In the perfect world, all academic papers
# are in standards-compliant PDF with proper metadata.
# In practice they come in all sizes and shapes:
# PostScript, DVI, or gzipped versions of those.
# This script homogenizes a directory with papers
# by converting them all to PDFs
#
# This file is public domain.
convert_all()
{
SUFFIX=$1
CONVERTOR=$2
PATTERN="s/\.$SUFFIX$/\.pdf/"
find . -type f -name "*.$SUFFIX" -print0 | while read -d $'\0' FILENAME; do
PDFNAME=$(echo $FILENAME | sed -e $PATTERN)
echo "$FILENAME -> $PDFNAME"
$CONVERTOR $FILENAME $PDFNAME
done
find . -type f -name "*.$SUFFIX" -delete
}
find . -type f -name "*.gz" | xargs gunzip
convert_all ps ps2pdf
convert_all dvi dvipdf