mkdir -p pdfs folder="00_contributions/FINAL/layout/" header="${folder}00_header.tex" footer="${folder}08_footer.tex" texts=( # "${folder}00_preface.tex" # "${folder}01_introduction.tex" "${folder}02_clara.tex" # "${folder}03_cengiz.tex" # "${folder}04_ren.tex" # "${folder}05_rosemary-interview.tex" # "${folder}06_michael.tex" # "${folder}07_biographies.tex" ) counter=1 for i in ${!texts[@]}; do file="${texts[$i]}" tmpfile="${file##*/}" cd pdfs/ rm $tmpfile cat ../$header >> $tmpfile echo "\setcounter{page}{$counter}" >> $tmpfile cat ../$file >> $tmpfile cat ../$footer >> $tmpfile xelatex $tmpfile num=$(pdfinfo "${tmpfile%.*}".pdf | grep Pages | sed 's/[^0-9]*//') cd ../ counter=$((counter+num)); done pdftk pdfs/*.pdf cat output vltk.pdf