TREE Command - Everything You Need To Know (Windows, CMD, DOS)

What does the tree command do?

The tree command can make it very easy for you to locate files and folders using the command line.
You can view how your directory is structured and where every file is located from your command prompt (CMD).
Upon typing tree in your command prompt you can see how your current as well as every sub directory within it is structured.

Tree

Any directories and sub directories will immediately show up forming a network or a tree of every folder, hence the name.
Tree without any parameters only displays directories or folders, to include files in the output use the /f parameter.

Tree /F

The CMD will immediately list every file and folder from your current directory and on wards.
To save the output of a tree command into a text file use the greater than redirector followed by the location in which you want to create your file as well as the name you want your file to have.

Tree /F > "C:\Users\Julian\Desktop\Output.txt"

In the example above i chose to create a text file named Output.txt in my desktop directory.
You can even tree to view the contents of your entire drive. Simply type tree followed by the label of the drive you want to view.

Tree C:\

Or alternatively use the %homedrive% environment variable followed by a backwards slash.

Tree %homedrive%\

It might take a while for this to complete, depending on the size of your drive, to stop the output simply press Control + C in your keyboard and the operation will be aborted at once.

Useful parameters for the tree command:

The tree command includes several useful parameters which you can use to alter its function.

 

  • /F Which will includes files in the output. Without this parameter the command line will only display folders.
  • /A Which will display ASCII instead of extended characters. This will basically make your tree look a bit more confusing (as if it wasn’t already).

Examples of the tree command:

Display every folder in the current directory and any sub directories:

Tree

List every file and folder in the current directory and any sub directories:

Tree /F

Show every file and folder starting from a specific directory, in this case the desktop folder.

Tree /F "C:\Users\Julian\Desktop"

Display the directory structure of a drive (replace the “C” character with the label of your drive):

Tree C:\ 

Display the directory structure of your entire home drive (usually C:\):

Tree %homedrive%\ 

Write the output of the command into a file.

Tree > "Output.txt"

Help output of the tree command:

Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.

Want to learn more about the Command Line?

Available on Udemy with a 70% discount.
Only for readers like you!

Scroll to top