TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am interested in running multiple latex files in a directory from perl. I will have as many as 100 .tex files to run at once, and I was wondering if someone could suggest a perl script or package that I could modify to do this quickly.

I am planning on generating the .tex files using exceltex (since it is a large database of questions), and then executing the perl script on the folder to generate the .pdf files.

Any advice would be appreciated.

share|improve this question
This shouldn't be too hard to do. But the exact method will depend on your directory/file structures. For example, will perl be called on all the files in some base directory? If not, is it possible to build a database of files you want to process through LaTeX? – A.Ellett Aug 8 '13 at 5:27
I think this is off-topic: while I see you got what looks like a good answer, it's not at all about TeX or something that TeX expertise helps with. – Joseph Wright Aug 8 '13 at 7:13
Hi Joseph: I guess I see what you mean, but I posted it here in case there was a .tex package that might help me do this. I didn't even know that exceltex existed before this forum. So, I'm sorry if this appeared to be an off-topic post. – MeTutel Aug 8 '13 at 13:17

If you're going to process all files in a directory, you can do something along the lines of

use strict 'vars';
my @files = <*.tex>;
foreach my $file ( @files )
    system("pdflatex $file");

Or if you have some file, call it tobe_compiled.txt, which lists names of file:


Then you could write a perl script as

open FILE, "<tobe_compiled.txt";
my @files = <FILE>;
close FILE;
foreach my $file ( @files )
    system("pdflatex $file");
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.