The Computer Oracle

How do I draw a tree file structure?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open

--

Chapters
00:00 How Do I Draw A Tree File Structure?
00:30 Accepted Answer Score 6
02:12 Answer 2 Score 3
02:42 Thank you

--

Full question
https://superuser.com/questions/272699/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows

#avk47



ACCEPTED ANSWER

Score 6


I use a command-line program called "dot" to draw tree structures. To do that, you create a text file defining each file or folder as a unique node and the connections between them (parent to child)

Dot is a part of the Graphviz toolkit, documentation is online at: http://www.graphviz.org/pdf/dotguide.pdf

It can output the drawing as PDF, SVG, PNG, JPG, etc.

Here's an example input file for the "dot" program (file name "test.dot"):

digraph "My File Tree Drawing" {
      /* paper size in inches */
      size="11.0,8.5";
      /* locate label at top of drawing */
      labelloc=t;
      label="My File Tree Drawing";
      /* no directional arrow on connectors */
      edge [dir=none];
      /* nodes below are boxes (folders) */
      node [shape=box];
      folder1 [label="Folder 1 Name"];
      folder2 [label="Folder 2 Name"];
      folder3 [label="Folder 3 Name"];
      /* nodes below are ellipses (files) */
      node [shape=ellipse];
      file1 [label="File 1 Name"];
      file2 [label="File 2 Name"];
      file3 [label="File 3 Name"];
      file4 [label="File 4 Name"];
      /* parent -> child, to draw the tree */
      folder1 -> folder2;
      folder1 -> folder3;
      folder1 -> file1;
      folder2 -> file2;
      folder3 -> file3;
      folder3 -> file4;
}

To make this into a pdf, you would run the command:

dot -T pdf test.dot > test.pdf

This program makes great drawings of file trees (or any tree / graph structure). The part that requires the most work is making the input *.dot file. I usually write a script to look through the file tree and output a text file formatted similar to "test.dot" above. Make sure that ALL NODE NAMES ARE UNIQUE (even if the label/file/folder name is the same). Another useful thing to know, each line in the *.dot file can come in almost any order - if any are duplicates, the last one will override the previous ones.

Additional "dot" documentation is available at http://www.graphviz.org/Documentation.php




ANSWER 2

Score 3


Treeviz - it's a Java app. I'm sure it will work on Windows, but I just happened to be on a Mac.

The trees are interactive. You can move things around and such with your mouse.

Interactive tree

Sunburst