1. notme

great job! that is what i was looking for!

• Happy to hear that. Thanks! Tom.

2. For Windows I would recommend some Powershell script. I’ll try to send you something.

• That would be awesome. Thanks! Tom.

• The following is the most basic Powershell script I could think of (in a quick & dirty way). If I find some time I will expand it to the level of your script:

clear-history
clear-Host

$a = "" + (pwd)$a = $a.Replace("\", "/") "\dirtree{%" ".1 " +$a + "."

$folders = gci | ? {$_.PSisContainer}

foreach ($i in$folders){
".2 " +$i.name.Replace("\", "/") +"." } "}" • Hi Uwe, Thanks for taking some time and providing the script above. I really appreciate it! I’ll give it a try the next time I get hold of a Windows computer. Thanks again! Tom. 3. The Perl script below should work on both Unix, Mac and Windows in order to generate the argument to \dirtree. It expects the top directory as argument on the command line; it does not need the external find command. #!/usr/bin/perl -w use strict; use File::Find; my$top = shift @ARGV;
die "specify top directory\n" unless defined $top; chdir$top or die "cannot chdir to $top:$!\n";

find(sub {
local $_ =$File::Find::name;
my @F = split '/';
printf ".%d %s.\n", scalar @F, @F==1 ? $top :$F[-1];
}, '.');
• Hi Arjen
Very nice! Thanks a lot for putting this script together.
Best, Tom.

• AntonG

Thanks for the script, it worked great for me under windows. The only problem was underscores in the filenames.
It would be cool to escape them with backslash right away, so that latex doesn’t throw errors on generated text.

• Hi Anton,

Thanks for your suggestion, I haven’t thought of that. Rather than replacing “_” with “\_” in batch or bash, you could also load the underscore package in the preamble of your document…

\documentclass{article}
\usepackage{underscore}
\begin{document}
under_score
\end{document}
• The underscore package causes problems when you import files with underscores in them. I prefer to just escape them in the “regular” way. Out this in the script to take care of that easily.

$_ =~ s/_/{\\_}/g; • tom Harald, thanks for you comment. Best, Tom • Grigory Thanks a lot for the article and script! If only the directories should be printed, the script should be modified next way: #!/usr/bin/perl -w use strict; use File::Find; my$top = shift @ARGV;
die "specify top directory\n" unless defined $top; chdir$top or die "cannot chdir to $top:$!\n";

find(sub {
#$File::Find::name; my @F = split '/',$File::Find::name;
printf ".%d %s.\n", scalar @F, @F==1 ? $top :$F[-1] if -d;
}, '.');
• Thanks, that’s great! Tom.

4. KLuka

Hey, I recently needed to do this in ruby to use the entries to render LaTeX

First I had one way and then my colleague wanted to get it done differently, so I even have two versions get the file listing 🙂

(if you only want output in the terminal then simply write puts before the function call 😉

• tom

Cool, thanks for sending the link!