Skip to content

What is TREE Windows command?

The Windows tree command is a built-in utility that displays the folder structure of a specified directory in a tree format in the command prompt. It helps users visualize the hierarchy of files and directories within a specific folder.

Terminal window
tree [drive:][path] [/F] [/A] [/Q] [/S] [/D] [/L n]
OptionDescription
/FDisplays the names of the files in each directory.
/AUses ASCII instead of extended characters.
/QDisplays the ownership of each file.
/SIncludes the subdirectories in the list.
/DLists the contents of each directory.
/L nSpecifies that the tree should only go up to a specific level n in the directory tree.
ParameterDescription
drive:Specifies the drive letter to display the tree from.
pathSpecifies the starting directory for the tree.
Terminal window
tree

This command displays the directory structure starting from the current directory.

Display Directory Structure with Subdirectories

Section titled “Display Directory Structure with Subdirectories”
Terminal window
tree /f

It displays the file names in addition to the directory structure.

Display Directory Structure with Specific Depth

Section titled “Display Directory Structure with Specific Depth”
Terminal window
tree /f /a 2

It shows the directory structure up to a depth of 2 levels along with file names.

Terminal window
tree /f /a > directory_structure.txt

This command saves the directory structure with file names to a text file named “directory_structure.txt”.

Display Directory Structure Including Hidden Files

Section titled “Display Directory Structure Including Hidden Files”
Terminal window
tree /a /f /h

It displays the directory structure including hidden files and folders.

To use the tree command in CMD, execute the following command:

Terminal window
tree

What option can I use to show the tree in Windows CMD?

Section titled “What option can I use to show the tree in Windows CMD?”

To display the directory structure in the Windows CMD using the tree command, you can use the /A option to specify ansi characters. Example:

Terminal window
tree /A

How can I include the filenames while using tree in Windows CMD?

Section titled “How can I include the filenames while using tree in Windows CMD?”

When using the tree command in Windows CMD, you can include filenames in the directory structure by using the /F option. Here’s an example:

Terminal window
tree /F

How do I display the tree structure with specific level of depth in Windows CMD?

Section titled “How do I display the tree structure with specific level of depth in Windows CMD?”

To display the tree structure up to a specific level of depth in Windows CMD using the tree command, you can use the /L option followed by the desired depth level. Example:

Terminal window
tree /L 2

Can I save the output of the tree command to a text file in Windows CMD?

Section titled “Can I save the output of the tree command to a text file in Windows CMD?”

Yes, you can save the output of the tree command to a text file in Windows CMD by using the output redirection operator (>). For example:

Terminal window
tree > output.txt

How to show only directories with tree in Windows CMD?

Section titled “How to show only directories with tree in Windows CMD?”

To exclusively display directories without files in the tree structure using the tree command in Windows CMD, you can use the /F and /A options together. Here’s an example:

Terminal window
tree /F /A

How do I exclude specific directories from the tree structure in Windows CMD?

Section titled “How do I exclude specific directories from the tree structure in Windows CMD?”

To exclude specific directories from the tree structure when using the tree command in Windows CMD, you can utilize the /I option followed by the directory name(s) to be excluded. Example:

Terminal window
tree /I "directory1" /I "directory2"

How to display the complete directory structure with tree in Windows CMD?

Section titled “How to display the complete directory structure with tree in Windows CMD?”

To display the complete directory structure in Windows CMD using the tree command, simply run the command without any additional options. Example:

Terminal window
tree
  • Display directory structure
  • List subdirectories and files within a directory
  • Show hierarchical view of folders and files
  • Print the structure of directories in a tree-like format
  • Help visualize the organization of files and folders