ASCII library for creating "Pretty" Directory Trees?

Is there any * nix or perl / php tool that allows you to easily create directory tree visualizations that look like this?

www |-- private | |-- app | | |-- php | | | |-- classes | | | +-- scripts | | |-- settings | | +-- sql | +-- lib | +-- ZendFramework-HEAD +-- public |-- css |-- images +-- scripts 
+62
unix php ascii tree
Oct 17 '09 at 6:18
source share
6 answers

How about this example from a Unix tree / tree tree :

 ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' 
+93
Oct 17 '09 at 7:02
source share

This oneliner is pretty cool, I would recommend using a tree .

 bash-3.2$ mkdir -p this/is/some/nested/example bash-3.2$ mkdir -p this/is/another/super/nested/example bash-3.2$ mkdir -p this/is/yet/another/example bash-3.2$ mkdir -p this/is/some/nested/other/example bash-3.2$ tree this this `-- is |-- another | `-- super | `-- nested | `-- example |-- some | `-- nested | |-- example | `-- other | `-- example `-- yet `-- another `-- example 13 directories, 0 files 
+69
Nov 14 '12 at 7:20
source share

See the RecursiveTreeIterator class

Allows iteration over a recursive Fighter to generate an ASCII graphics tree.

 $treeIterator = new RecursiveTreeIterator( new RecursiveDirectoryIterator('/path/to/dir'), RecursiveTreeIterator::SELF_FIRST); foreach($treeIterator as $val) echo $val, PHP_EOL; 

The result will be something like this (with c: \ php on my machine):

 |-c:\php5\cfg |-c:\php5\data | |-c:\php5\data\Base | | \-c:\php5\data\Base\design | | |-c:\php5\data\Base\design\class_diagram.png | | \-c:\php5\data\Base\design\design.txt | |-c:\php5\data\ConsoleTools | | \-c:\php5\data\ConsoleTools\design | | |-c:\php5\data\ConsoleTools\design\class_diagram.png | | |-c:\php5\data\ConsoleTools\design\console.png | | |-c:\php5\data\ConsoleTools\design\console.xml … 
+16
Nov 16 '10 at 16:23
source share

I understand that this question was asked many years ago, but I just found this program called tree , which is also pretty cool.

+15
Jun 10 '10 at 22:33
source share

Check out the App :: Asciio

0
Oct 17 '09 at 8:17
source share

Cool Python script to do this: http://code.activestate.com/recipes/217212/

0
Feb 04 '11 at 19:52
source share



All Articles