Skip to content

Instantly share code, notes, and snippets.

@cllu
Created April 18, 2017 02:52
Show Gist options
  • Save cllu/68bc52db9408be16edb0cade1bb73615 to your computer and use it in GitHub Desktop.
Save cllu/68bc52db9408be16edb0cade1bb73615 to your computer and use it in GitHub Desktop.
#!/bin/bash
conversion (){
# get file name without extension, full path
b="${1%%.*}"
b=`basename $b`
full=`grealpath $1`
echo "Converting: $1 (Absolute path: $full)"
dir="`dirname $full`/eps"
mkdir -p $dir
pdftops -eps $full
mv "`dirname $full`/$b.eps" ${dir}/${b}.eps 2>/dev/null
if [ $? -ne 0 ]; then echo "pdftops failed" && pdftops=false; fi
}
if [[ -f $1 ]]; then
# if a single file
conversion $1
elif [[ -d $1 ]]; then
# else if a directory
for i in `ls $1/*.pdf`; do
conversion $i
done
else
echo "Call: ./pdf2eps [PDF file]"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment