ALL files and ALL folders
For a text file of ALL files and Folders in your Home Directory,
In Terminal, enter:
find ~ -print | sed -e 's;[^/]*/;|--->;g;s;--->|; |;g' > ~/Desktop/Tree.txt
To direct to a specific Folder, replace ~ with the Directory (i.e. find ~/Documents):
find ~/Documents -print | sed -e 's;[^/]*/;|--->;g;s;--->|; |;g' > ~/Desktop/Tree.txt
NO files and ALL folders
Before -print add
-type d
Leave spaces around it.
Listings from mounted devices
find mount/Volumes/path/to/dir -type d -print | sed -e 's;[^/]*/;|--->;g;s;--->|; |;g' > ~/Desktop/Tree.txt
source: discussions.apple.com