X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=arxiv-rename-pdf.sh;fp=arxiv-rename-pdf.sh;h=5ec49c0c66f936ec9ead22dc728c56f190c028a8;hb=bc0354cbdfeb98441e3e308160c2c4221dad32cc;hp=0000000000000000000000000000000000000000;hpb=6132e6b801b132ffd5faf364b0da360d9986b0b3;p=scripts.git diff --git a/arxiv-rename-pdf.sh b/arxiv-rename-pdf.sh new file mode 100755 index 0000000..5ec49c0 --- /dev/null +++ b/arxiv-rename-pdf.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +######################################################################### +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the version 3 of the GNU General Public License # +# as published by the Free Software Foundation. # +# # +# This program is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # +# General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# Written by and Copyright (C) Francois Fleuret # +# Contact for comments & bug reports # +######################################################################### + + +set -e +set -o pipefail + +ARXIV_BIBFILE="${HOME}/tex/teaching/dlc/dlc.bib" + +tmp=$(mktemp /tmp/arxiv-bib.sh.XXXXXX) + +while [[ "$1" ]] +do + + if [[ $1 =~ ^http ]] + then + wget "$1" + id="$(echo "$1" | sed -e 's|^.*/\([^\]*\)$|\1|')" + filename="${id}.pdf" + else + filename="$1" + id="$(basename ${filename} .pdf)" + fi + + echo -n "Fetching info from arxiv.org ... " + + curl -s > "${tmp}" "https://arxiv.org/abs/${id}" + + echo "done." + + ###################################################################### + # Bibtex entry + + AUTHORS="" + + while read line + do + [[ "${AUTHORS}" ]] && AUTHORS="${AUTHORS} and " + AUTHORS="${AUTHORS}${line}" + done < <(grep -q '> ${ARXIV_BIBFILE} <