123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #!/bin/bash
- input=""
- output=""
- authors=""
- title=""
- venue=""
- year=""
- notice=""
- while [ "$#" -gt 0 ]; do
- case "$1" in
- "--input")
- input="$2"
- shift 2
- ;;
-
- "--output")
- output="$2"
- shift 2
- ;;
-
- "--authors")
- authors="$2"
- shift 2
- ;;
-
- "--title")
- title="$2"
- shift 2
- ;;
-
- "--venue")
- venue="$2"
- shift 2
- ;;
-
- "--year")
- year="$2"
- shift 2
- ;;
-
- "--notice")
- notice="$2"
- shift 2
- ;;
-
- "--help")
- echo "Usage: bash addcopyright.sh --input INPUT --output OUTPUT --authors AUTHORS --title PAPERTITLE --venue VENUE --year YEAR --notice COPYRIGHT_NOTICE"
- exit
- ;;
-
- *)
- echo "Invalid value: $$1"
- echo
- echo "Usage: bash addcopyright.sh --input INPUT --output OUTPUT --authors AUTHORS --title PAPERTITLE --venue VENUE --year YEAR --notice COPYRIGHT_NOTICE"
- exit
- ;;
- esac
- done
- if [ "$input" = "" ]; then
- echo "Input file is missing. Please provide this value with --input."
- exit
- fi
- if [ "$output" = "" ]; then
- echo "Output file is missing. Please provide this value with --output."
- exit
- fi
- if [ "$authors" = "" ]; then
- echo "Authors are missing. Please provide this value with --authors."
- exit
- fi
- if [ "$title" = "" ]; then
- echo "Paper title is missing. Please provide this value with --title."
- exit
- fi
- if [ "$venue" = "" ]; then
- echo "Venue is missing. Please provide this value with --venue."
- exit
- fi
- if [ "$year" = "" ]; then
- echo "Year is missing. Please provide this value with --year."
- exit
- fi
- if [ "$notice" = "" ]; then
- echo "Copyright notice is missing. Please provide this value with --notice."
- exit
- fi
- input=$(realpath "$input")
- output=$(realpath "$output")
- output_dir=$(dirname $output)
- output_fname=$(basename $output)
- output_fname="${output_fname%.*}"
- thisdir=$(dirname "$0")
- cat "$thisdir/template.tex" | \
- sed 's~<INPUT>~'"$input"'~g' | \
- sed 's~<AUTHORS>~'"$authors"'~g' | \
- sed 's~<TITLE>~'"$title"'~g' | \
- sed 's~<VENUE>~'"$venue"'~g' | \
- sed 's~<YEAR>~'"$year"'~g' | \
- sed 's~<CNOTICE>~'"$notice"'~g' > temp.tex
- pdflatex temp.tex
- pdflatex temp.tex
- mv temp.pdf "$output"
- rm -f temp.aux temp.fdb_latexmk temp.fls temp.log temp.out temp.synctex.gz temp.tex
|