2.13.2013

How to Print or Save a List of Directories to a Certain Depth in Windows

A solution for this simple task took me over an hour to find. I needed to print a list of directories on one of my computer's drives. I also needed to recursively print these directories' subdirectories, but only to about 4 levels down. Linux has simple shell commands for this, but I'm running Windows XP.

An open-source program called "Tree for Windows" had my solution. You can find it here:

I ran this from a DOS prompt using these switches:
tree -d -L 4 -o list.txt x:\
-d prints only directories
-L 4 prints subsdirectories to 4 levels deep
-o list.txt saves the output in a text file
x:\ is the path you want to print