Skip to content

Instantly share code, notes, and snippets.

@Deadlyelder
Created June 30, 2020 19:27
Show Gist options
  • Save Deadlyelder/0b48212e0a14c75c1c2e6247c8618dde to your computer and use it in GitHub Desktop.
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
#!/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