Created
June 30, 2020 19:27
-
-
Save Deadlyelder/0b48212e0a14c75c1c2e6247c8618dde to your computer and use it in GitHub Desktop.
Academic convert script for annoying papers from DVI, PS and gzip to PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment