Recently I had the need to produce a text file containing the directory structure of a folder and all its content.
tree command is just what I needed. A quick
brew install tree installed it on my Mac.
One would think that it would just be a matter of running
tree /path/to/folder > /path/to/tree.txt
That’s true, for small directories (or those with no special characters?), for others I get this lovely crap:
Turns out the fix is pretty easy (altough you loose non ASCII characters in file names):
LC_ALL=C tree /path/to/folder > /path/to/tree.txt