#!/bin/sh ## Endre desse variablane: W2LJAR=/home/brukar/latex/writer2latex.jar CONFIG=/home/brukar/latex/zotero-apa.xml BIB=/home/brukar/latex/minbibliografi # utan .bib til slutt STYLE=apalike ## Du skal ikkje trenge endre noko under denne linja if [ "$#" -ne 1 ]; then echo "Bruk: sh odt-to-lyx.sh dokument.odt"; exit 1; fi ODT="$1" TEX=$(echo "${ODT}" | sed 's/\.odt$/.tex/') LYX=$(echo "${ODT}" | sed 's/\.odt$/.lyx/') rm -f "${TEX}" java -jar ${W2LJAR} -latex -config=${CONFIG} "${ODT}" "${TEX}" # Java unfortunately doesn't give any helpful exit codes, so we just # check if the file was created: if [ -f "${TEX}" ]; then # Insert our bibliography, writer2latex can't do this: sed -i".tmp" "s%\\\\end{document}%\n\\\\bibliographystyle{${STYLE}}\n\\\\bibliography{${BIB}}\n\\\\end{document}%g" "${TEX}" rm -f "${TEX}.tmp" # Make a backup of any existing LyX file, just in case: if [ -f "${LYX}" ]; then LYXBAK=$(mktemp "${LYX}.gammal.XXXXX") mv "${LYX}" "${LYXBAK}" fi tex2lyx "${TEX}" fi