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'd like to print the complete source code of my java project, which has multiple .java files in several packages (i.e. folders), many .properties files and many .xml files, and others.

I want to use \lstinputlisting from the listings package but I don't want to add these commands one by one to the document.

The alternative would be to write some script that generates a file with those \lstinputlisting commands for all files, however I'd rather want to know if such a program already exists.

share|improve this question
Something like find . -name "*.java" | awk '{print "\\lstinputlisting[style=java]{"$0"}";}' >javalistings.tex? – Daniel Aug 16 '12 at 20:25
I'm using Windows. – Gabriel Belingueres Aug 17 '12 at 11:14
@GabrielBelingueres, that is OK. Either install VBox and put Linux on it (both free) and then mount shared your windows disk into Linux. Or install Cygwin directly into windows, also free. Then you can use the above command by Daniel on windows. – Nasser Jan 22 '13 at 4:31
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Jubobs Mar 2 '14 at 13:17

If you use a Unix OS you can execute the following command:

find . -name "*.java" | awk '{print "\\lstinputlisting[style=java]{"$0"}";}' >javalistings.tex

If you are using Windows you can install CygWin to get an Unix-Shell.

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.