Generate File System Trees in CSV Format with "tree" and "sed"
Description
I don't know whether this will be useful to anyone else, but I wanted to use the Linux tree command to generate file system trees in CSV format on OS X. This should work pretty much as is on Linux, although you may need or want to change the paths and optimize the usage of sed.
Dependency
This uses the Linux "tree" command, which is not standard on OS X.
"tree" Source Code
"The Tree Command for Linux Homepage"
"tree" Installation Reference
"Terminal fun: Options for printing folder and subfolder contents - CNET"
"tree" Usage Reference
"Linux and Unix tree command help and examples"
Please Note
OS X uses BSD sed, not GNU sed. Thus, the sed portion of the following could probably be more concise with the GNU version of sed.
Commands
This will generate a file system tree with just directories in CSV format:
tree -ad --noreport | sed -e "s/├── /,/g" -e "s/└── /,/g" -e "s/│ /,/g" -e "s/ /,/g" > ~/Desktop/"${PWD##*/} tree (just dirs).csv"
This will generate a file system tree with both directories and files in CSV format:
tree -a -I \.git --noreport | sed -e "s/├── /,/g" -e "s/└── /,/g" -e "s/│ /,/g" -e "s/ /,/g" > ~/Desktop/"${PWD##*/} tree.csv"