I want to compile a bunch of (independent) documents from a main.tex file. The documents are in subfolders and as they can load input files and graphics from other subfolders I need to change the current directory. I think this can't be done inside a \write18 call so I'm writing first a .bat-script and call this later. I would like to adapt the code so that is works on linux too, but as I don't have a linux system available I can't test it. Could someone tell me how this should look on linux? (You need folders a1 and a2 with a1.tex and a2.tex in them.)
\documentclass{article}
\begin{document}
\newwrite\writebatch
\immediate\openout\writebatch=compile-files.txt
\immediate\write\writebatch{cd a1}
\immediate\write\writebatch{pdflatex a1}
\immediate\write\writebatch{cd ..}
\immediate\write\writebatch{cd a2}
\immediate\write\writebatch{pdflatex a2}
\immediate\closeout\writebatch
\immediate\write18{copy compile-files.txt compile-files.bat}
\immediate\write18{compile-files.bat}
%compile-files.bat will probably be called later on the command line, is here for
%the test. Needs --shell-escape.
\end{document}
arara.:)– Paulo Cereda May 04 '14 at 09:38pdflatex \def\startnumber{50}\input{a1}. 3. The main document at the end should include the pdfs. – Ulrike Fischer May 04 '14 at 09:53