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 have several plots saved as .pdf in a folder and I would like to know if there is a way of adding all of them in a document at once, without typing the path to each file.

share|improve this question
short answer no, longer answer, if you are prepared to allow latex to escape to the shell and run system commands, and don't mind your document being system dependent you could get it to run ls *.pdf(or whatever is needed) and construct the list. (or you could just do this before starting latex) – David Carlisle Feb 18 '14 at 17:39
up vote 10 down vote accepted

It is best to do this externally to latex (although you can use the shell-escape (write18) feature to execute the commands from within latex if you want.

I'll assume bash syntax but other command line systems can do similar.

Suppose you have a directory/folder img with three pdf files

$ ls img
a.pdf  b.pdf  other.pdf

and you want to include them in alphabetic order (or any other order you can achieve by using arguments to ls or some other command)

then executing

ls img/*.pdf | sed -e "s/.*/\\\\includegraphics{\\0}/" > img/imglist.tex

would leave a file img/imglist.tex that looks like


so you just need \input{img/imglist} in your main file, and arrange to regenerate imglist.tex every time you update the image directory (or every time you run latex).

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.