Am Dienstag, den 02.03.2010, 22:21 -0500 schrieb Armelius Cameron:
I am wondering if anyone knows any tool to generate a graphical
representation
of directory structure as a tree. Directories would be a node, files would be
leaves. I know about the command line "tree". It's similar, but not exactly
what I need. It'd be nice to be able to rotate something like the output of
"tree" command line 90 degree, so that the siblings are on the same horizontal
level. Also, preferably the output is in SVG, so I can edit it using e.g.
Inkscape. But if not, I guess other formal (i.e. PNG, PS) is a possibility
too.
I know about Graphviz. So if I can't find anything I guess I can try to do this
myself and code up something. I just didn't want to do the work if something
is already out there :) . If there are other tools similar to Graphviz (maybe
something simpler), I'd like to hear about it too.
Maybe this graphviz I used once will help, it generates a PNG. I used
some recursion, but no clue about doing it with just one command (find,
tree, may..be?)
---
#!/bin/bash
function recurse () {
SUBS=$(find $1 -mindepth 1 -maxdepth 1 -type d)
for a in $SUBS
do
echo "\"$1\" -> \"$a\";" >> $DOTFILE
recurse $a
done
}
DOTFILE=$(mktemp)
export IFS=$'\n'
echo "digraph unix {" > $DOTFILE
echo "node [color=lightblue2, style=filled];" >> $DOTFILE
recurse $1
echo "}" >> $DOTFILE
dot -Tpng $DOTFILE > dirs.png
eog dirs.png &
---
Call it with drawrecurse.bash /home/myuser/mytree. You can modify it in
many ways, and change graphviz options to get your desired output.
Greets!
----------------------------------------------
Rodolfo Alcazar - rodolfo.alcazar(a)padep.org.bo
otbits.blogspot.com /
counter.li.org: #367962
----------------------------------------------
/* I can C clearly now */