It has been tested many times in my daily projects. Compile it with pdflatex --shell-escape executor.tex
. And you will get 5 PDF files: 4 identical PDF files (a.pdf
, b.pdf
, c.pdf
, d.pdf
) and executor.pdf
that can be regarded as a log file.
% this file name is executor.tex
% compile it with pdflatex -shell-escape executor.tex
\documentclass{minimal}
\usepackage{filecontents}
\begin{filecontents*}{foo.tex}
\documentclass{article}
\usepackage[a6paper,margin=3cm]{geometry}
\begin{document}
\LaTeX\ is fun!
\end{document}
\end{filecontents*}
\makeatletter
% make a master
\immediate\write18{pdflatex foo.tex}
\@for\ext:={tex,dvi,ps,log,aux,out,toc,nav,snm}\do{\immediate\write18{cmd /c del foo.\ext}}%
% make multiple copies
\@for\filename:={a,b,c,d}\do{\immediate\write18{cmd /c copy foo.pdf \filename.pdf}}
\makeatother
\begin{document}
Done!
\end{document}
Explanation:
The executor.tex
is an auxiliary input file to automate the process of compiling the foo.tex
for multiple output names (a.pdf
, b.pdf
, c.pdf
, d.pdf
).
Disclaimer:
The multiple copies are not guaranteed to be 100% identical because the time stamp (creation date time, etc) for each file might not be identical.
perl
orbash
script; but as detailed in how-to-influence-the-name-of-the-pdf-file-created-with-pdflatex-from-within-the it is not possible to influence the name of\jobname.pdf
from within the.tex
file – cmhughes Sep 26 '12 at 20:00pdflatex foo.tex && cp foo.pdf fooxy.pdf
– N.N. Sep 26 '12 at 20:00pdflatex
, unless a modification in the program source code to flush data to two output streams at the same time. Even by runningpdflatex
on the same.tex
file will produce different checksums every time. The only way to garantee a 1:1 copy is, well, by copying the target.pdf
file. – Paulo Cereda Sep 26 '12 at 22:35