CMD Simulator
File Managementtree

TREE Command – Display Directory Structure in Windows

Learn how to use the TREE command to display folder and file hierarchy in Windows Command Prompt. Syntax, /F and /A options, examples, and when to use TREE vs DIR.

Rojan Acharya··Updated Mar 15, 2026
Share

The TREE command is a Windows Command Prompt utility that displays the directory structure of a drive or path in a graphical tree format. Use TREE to show folders (and optionally files with /F) in a hierarchical view—ideal for documenting folder layouts, auditing project structure, or quickly visualizing where files live.

Whether you're a developer documenting a repo layout, an IT admin auditing shared drives, or a power user organizing projects, TREE gives you a clear picture of directory hierarchy without opening Explorer. Scripts and batch files use TREE to generate structure reports or pipe the output to files for documentation.

This guide covers TREE syntax, the /F and /A parameters, practical examples, common use cases, tips, troubleshooting, related commands, and frequently asked questions.

What Is the TREE Command?

The TREE command has been part of Windows (and MS-DOS) for decades. It outputs a text-based tree of directories (and optionally files) under a given path, using characters like ├── and └── (or ASCII alternatives with /A) to show parent-child relationships.

TREE runs in Command Prompt (CMD), works in Windows Terminal, and is available in all modern Windows versions. It does not change any files or directories; it only displays structure. Use it when you need a quick hierarchy view or when you want to export a folder layout to a file.

TREE Command Syntax

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

Parameters and Switches

ParameterDescription
[drive:][path]Drive and/or directory to display. Default is current directory.
/FDisplay the names of files in each folder (not just directories).
/AUse ASCII characters instead of extended characters for tree lines (better for some terminals and log files).

If you omit path, TREE uses the current directory. Omit /F to show only folders.

Examples

Display tree of current directory

TREE

Shows folder structure under the current drive and path. Only directories are listed.

Display tree including files (/F)

TREE /F

Lists every file and folder in the hierarchy. Use for full project or volume structure.

Display tree of a specific path

TREE C:\Projects
TREE D:\Backup

Use any valid path. TREE will report "Directory not found" if the path does not exist.

Use ASCII characters (/A)

TREE /A
TREE C:\Windows /F /A

Use /A when piping to a file or when your console does not display box-drawing characters correctly.

Export directory structure to a file

TREE /F > project-structure.txt
TREE C:\Apps /F /A >> doc.txt

Redirect output to create documentation or compare structures over time.

Common Use Cases

  1. Documenting project layout – Run TREE /F from the project root and save to README or docs.
  2. Auditing shared drives – View folder hierarchy before cleanup or migration.
  3. Comparing before/after – Save TREE output before and after reorganizing to verify structure.
  4. Scripting and automation – Pipe TREE into other commands or log files.
  5. Troubleshooting path issues – See exactly where folders sit relative to a drive or path.

Tips and Best Practices

  1. Use /F sparingly on large trees – Output can be very long; consider a specific subpath.
  2. Combine with redirectionTREE /F > structure.txt for documentation.
  3. Use /A in scripts – ASCII output is more portable across systems and editors.
  4. Check the path first – Use DIR or CD to confirm the path exists before running TREE.

Troubleshooting Common Issues

"Directory not found"

The specified path is invalid or does not exist. Use CD [path] or DIR [path] to verify, and use absolute paths (e.g. C:\Folder) in scripts.

Tree output is too long

Limit scope by specifying a deeper subpath, or redirect to a file and open in an editor. Avoid TREE C:\ /F on large drives without redirection.

Characters display incorrectly

Use the /A switch to get ASCII-only tree characters that display correctly in all consoles and log files.

Related Commands

  • DIR – List contents of a single directory (flat list). Use DIR for one-level listing; TREE for hierarchy.
  • CD / CHDIR – Change current directory. Use before TREE to set the root, or pass path to TREE.
  • XCOPY, ROBOCOPY – Copy directory trees; TREE only displays structure.

Frequently Asked Questions

What does TREE /F do?

TREE /F displays both directories and files in the tree. Without /F, only folder names are shown.

Can TREE show only a certain depth?

Standard TREE does not support depth limits. For limited depth, use DIR with recursion or PowerShell (e.g. Get-ChildItem -Recurse -Depth).

Does TREE work in PowerShell?

Yes. You can run cmd /c tree ... from PowerShell, or use PowerShell’s own cmdlets (e.g. Get-ChildItem) for tree-like output.

How do I save TREE output to a file?

Use redirection: TREE /F > output.txt or TREE C:\Projects /A >> log.txt.

Quick Reference Card

CommandPurposeExample
TREETree of current directory (folders only)TREE
TREE /FTree including filesTREE /F
TREE pathTree of given pathTREE C:\Projects
TREE /AUse ASCII tree charactersTREE /A
TREE /F > file.txtSave full tree to fileTREE /F > structure.txt

Summary

The TREE command displays directory (and with /F, file) hierarchy in a tree format. Use it to document structure, audit folders, or pipe hierarchy into files. For single-level listing use DIR; for copying directory trees use XCOPY or ROBOCOPY.

Practice TREE in the Windows Command Simulator. Browse the Commands Reference for DIR, CD, and other file and directory commands.