I’ve a problem. How can I create a directory list with all
sub-directories and files like this:
If you really want to output an indented tree-like view of a directory
along with its subdirectories, then the Find module may not be the
best tool insofar as it produces a “flattened” view of your directory
structure. You’ll have to do some additional work to “unflatten” it
back into a tree structure. Because of this, you may be better off
performing your own directory traversal rather than relying on Find.
Something along the following lines will give you an indented view:
On a lot of systems you can use the ‘tree’ command.
Try:
ruby -e “puts tree
” (or ruby -e “puts tree.COM
” on windows).