When I run tree /a /f > output.txt
in Windows' cmd, I get a nicely formatted directory structure. But the directory listing is not in any particular order. How can I get the tree to sort folders and files in alphabetical order?
Note: I need the output formatted as a hierarchy, so using dir
will probably not be sufficient. I probably need to use tree
.
An excerpt from the output of tree
+---HCM Documents
| +---Interfaces
| +---Process Flows
| +---Workshops
| | \---Overviews
| +---Approvals
| +---Requirements
| \---Misc
+---Testing Documents
+---Communications
| +---Statuses
| +---Meeting Minutes
+---Finance Documents
| +---Taxes
| +---General Ledger
| +---Business
| +---Process Flows
| +---Purchases
| \---Workshops
+---Unfiled
+---Infrastructure Documents
+---Financials
| +---Issue and Risk Log
| +---Timelines
| +---Templates
| \---Decisions Log
Note that the folder names are not in alphabetical order. They are also not in order of modified date or size, or any other order I can think of.
Also, this is the default order I get when I run dir
without specifying sort order.
These documents are being accessed over a network drive but I don't see why that should make a difference. (Though when I run tree on local folders, they do seem to be in alphabetical order. Perhaps this is actually a factor?)
tree
does not take the sorting directly fromdir
. It uses it's ownfindfirst
andfindnext
so theDIRCMD
has no effect. It does work on thedir
-command. Just tested this with a Linux server where the order is also messed up. Unfortunatelytree
stays un-ordered.