What I did on Windows was create a .bat file and put this in tree "%CD%" > "%CD%\file.txt" /A /F
.
I know that %CD% isn't available in macOS.
%CD% takes the path where the .bat file is located.
I tried using pwd but that only takes /Users/[current_user] and that's not what I wanted. Is there a way to get the path where the .command file is located?
Before saying cd path/to/dir ... the path is unknown. It has to take the path where it currently is.