How do I draw a tree file structure?

I'm looking for a (portable) software or script that would allow me to draw a specific file structure as a tree, in Windows XP. Much like DOS tree command, but "prettier" (as a graph or diagram)

I already tried TreeSize but it doesn't suit my needs, as it does not offer any export options nor graphical tweaks.


Solution 1:

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

Solution 2:

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