A directory-tree generation script for LaTeX
A python script that automagically generates the code to represent a directory tree in LaTeX using the dirtree package.
> python dirtreex.py /Users/me/myDir
\dirtree{%
.1 {/Users/me/myDir} .
.2 {A} .
.3 {A1} .
.3 {A2} .
.3 {A3} .
.2 {B} .
.3 {B1} .
.4 {B1.2} .
.5 {beta} .
.2 {C} .
.3 {a:b:c} .
.4 {gamma} .
}
The previous code renders in LaTeX as follows:
Yep
> python dirtreex.py -h
usage: dirtreex.py [-h] [-d MAXDEPTH] [-H] [-S] path
Print the directory-tree code for the LaTeX dirtree package.
positional arguments:
path Root directory of the tree
optional arguments:
-h, --help show this help message and exit
-d MAXDEPTH, --maxDepth MAXDEPTH
Max depth for the tree expansion
-H, --includeHidden Include hidden files
-S, --includeSystem Include system files
Nope. I wrote this for OS X and it should be compatible with any Unix system.
The -H
flag shouldn't work on Windows due to a different representation of hidden files.
Obviously you will need Python (tested on 2.7) and then install the walkdir
library:
pip install walkdir
Direct link here or checkout the repository.
the quick way:
> python /path/to/script/dirtreex.py /treeRoot
the other way:
> sudo chmod +x /path/to/script/dirtreex.py
> mv /path/to/script/dirtree.py /usr/local/bin
> dirtreex.py /treeRoot