I just made a batch script for this myself (for Windows).
FOR /L %%X IN (1,1,5) DO (
IF EXIST %%X.tex (
TYPE start.tex > temp.tex
TYPE %%X.tex >> temp.tex
TYPE stop.tex >>temp.tex
pdflatex -synctex=0 -interaction=nonstopmode -shell-escape -jobname=%%X temp
FOR /L %%X IN (1,1,5) DO ( DEL %%X.aux & DEL %%X.log & DEL %%X.out)
2.tex, ... ,
5.tex (the name of your files) in a directory with this script (named
whatever.bat). Make a
start.tex file (in the same directory) which looks like
and a stop.tex file (in the same directory) containing
What the script does is, checks if a file
1.tex exists, and if so, writes
temp.tex, include the text in
temp.tex and compiles
temp.tex with the name
1.pdf. Then moves on to
2.tex, and so on.
The line before the
PAUSE command removes auxiliary files. You may want to remove this line.
You might also want to change the
If you get more documents, change the (or both)
for loop to
(start,step,stop), that is
(1,1,10) for 10 documents.
Please not that this is my first batch script ever and i strongly recommend you to take copies of what you've written before you use it. If you're on Linux, perhaps someone can write a
bash script (I don't have access to Linux right now).
Edit: Please use jhor's one instead. Mine is, as pointed out, a beginner's one. For me, the numbering was important (solution files in a textbook, attached in pdf to specific questions which could then be thrown around at will), hence the simple for-loop which gets the work done.