I just made a batch script for this myself (for Windows).
@ECHO off
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)
PAUSE
Place 1.tex, 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
\documentclass{someclass}
some preamble
\begin{document}
and a stop.tex file (in the same directory) containing
\end{document}
What the script does is, checks if a file 1.tex exists, and if so, writes start.tex to temp.tex, include the text in 1.tex in temp.tex, writes stop.tex to 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 pdflatex options.
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.
\documentclass{mylocalclass}\begin{document}.....\end{document}and put all the shared code in the document class file. – David Carlisle Jul 21 '13 at 10:11\usepackage{mylocalstyle}. – Steven B. Segletes Jul 23 '13 at 13:01