addcopyright.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. input=""
  3. output=""
  4. authors=""
  5. title=""
  6. venue=""
  7. year=""
  8. notice=""
  9. while [ "$#" -gt 0 ]; do
  10. case "$1" in
  11. "--input")
  12. input="$2"
  13. shift 2
  14. ;;
  15. "--output")
  16. output="$2"
  17. shift 2
  18. ;;
  19. "--authors")
  20. authors="$2"
  21. shift 2
  22. ;;
  23. "--title")
  24. title="$2"
  25. shift 2
  26. ;;
  27. "--venue")
  28. venue="$2"
  29. shift 2
  30. ;;
  31. "--year")
  32. year="$2"
  33. shift 2
  34. ;;
  35. "--notice")
  36. notice="$2"
  37. shift 2
  38. ;;
  39. "--help")
  40. echo "Usage: bash addcopyright.sh --input INPUT --output OUTPUT --authors AUTHORS --title PAPERTITLE --venue VENUE --year YEAR --notice COPYRIGHT_NOTICE"
  41. exit
  42. ;;
  43. *)
  44. echo "Invalid value: $$1"
  45. echo
  46. echo "Usage: bash addcopyright.sh --input INPUT --output OUTPUT --authors AUTHORS --title PAPERTITLE --venue VENUE --year YEAR --notice COPYRIGHT_NOTICE"
  47. exit
  48. ;;
  49. esac
  50. done
  51. if [ "$input" = "" ]; then
  52. echo "Input file is missing. Please provide this value with --input."
  53. exit
  54. fi
  55. if [ "$output" = "" ]; then
  56. echo "Output file is missing. Please provide this value with --output."
  57. exit
  58. fi
  59. if [ "$authors" = "" ]; then
  60. echo "Authors are missing. Please provide this value with --authors."
  61. exit
  62. fi
  63. if [ "$title" = "" ]; then
  64. echo "Paper title is missing. Please provide this value with --title."
  65. exit
  66. fi
  67. if [ "$venue" = "" ]; then
  68. echo "Venue is missing. Please provide this value with --venue."
  69. exit
  70. fi
  71. if [ "$year" = "" ]; then
  72. echo "Year is missing. Please provide this value with --year."
  73. exit
  74. fi
  75. if [ "$notice" = "" ]; then
  76. echo "Copyright notice is missing. Please provide this value with --notice."
  77. exit
  78. fi
  79. input=$(realpath "$input")
  80. output=$(realpath "$output")
  81. output_dir=$(dirname $output)
  82. output_fname=$(basename $output)
  83. output_fname="${output_fname%.*}"
  84. thisdir=$(dirname "$0")
  85. cat "$thisdir/template.tex" | \
  86. sed 's~<INPUT>~'"$input"'~g' | \
  87. sed 's~<AUTHORS>~'"$authors"'~g' | \
  88. sed 's~<TITLE>~'"$title"'~g' | \
  89. sed 's~<VENUE>~'"$venue"'~g' | \
  90. sed 's~<YEAR>~'"$year"'~g' | \
  91. sed 's~<CNOTICE>~'"$notice"'~g' > temp.tex
  92. pdflatex temp.tex
  93. pdflatex temp.tex
  94. mv temp.pdf "$output"
  95. rm -f temp.aux temp.fdb_latexmk temp.fls temp.log temp.out temp.synctex.gz temp.tex