#!/bin/bash for f in *.tex; do # Skip files that are already wrappers or special files [[ "$f" == *-w.tex ]] && continue [[ "$f" == _* ]] && continue [[ "$f" == BiblioRef.tex ]] && continue base="${f%.tex}" wrapper="${base}-w.tex" cat > "$wrapper" << EOF % !TEX root = ${wrapper} % ${wrapper} \input {_header} \excludecomment{glossarytext} \input {_glossary} \begin{document} \input{_BiblioRef} \input{${base}} \includecomment{glossarytext} \input {_glossary} \end{document} EOF echo "Created ${wrapper}" done