View all your Files & Folders – TREE Command – Directory Structure (Windows, CMD, DOS)

What We'll Learn:

Welcome!
This guide is all about viewing our directory structure from the windows command line (cmd) using the tree command.

  • We’ll start by learning, how to view the directory structure of a directory.
  • How to view the directory structure of our entire drive using the Tree command.
  • And finally, we’ll take a look at a few more useful parameters and a few usage examples for the Tree command.

Lets get started!

Directory Structure - Using TREE​:

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
Directory Structure - TREE Command, Examples & Parameters (Windows, CMD)

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.

View Your Entire Drive's Structure​:

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.

Summary:

  • Use the Tree command without any parameters to view the stricture of your current directory.
  • To view your entire drives directory structure simply enter the name of your drive after the Tree command.
  • Use the /F parameter to include files in the output or /A to display ASCII instead of extended characters.

That's It!

You now know how to use the Tree command in the windows command line.

If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows command Line.

Dont Stop Learning!

Windows Command Line Course!

This course has everything you need to start learning about the windows command line along with batch scripting.

Read More:

Any Questions? Ask them Below:

Leave a Reply

Your email address will not be published.

Take Your Skills to the next level!
Become one of our beloved students by enrolling into one of our courses. Get started now!

FREE Command Line Course!

Learn the Windows command line And Become an Expert!