How to show a folder tree

Overview

tree draws the directory hierarchy beneath a path, which helps explain project layouts and locate deeply nested folders.

By default it shows directories only. It is read-only, but running it at a large drive root may produce lengthy output.

  • Run it on a small folder first.
  • Redirect output to create a shareable text map.
  • The tree is a snapshot and does not update automatically.

Commands to try

Type each command at the prompt, then press Enter. Replace sample names and paths with ones that exist on your computer.

Commands are generally not case-sensitive, but preserving the spelling shown here makes scripts easier to read.

tree
tree "%USERPROFILE%\Documents"
tree /f /a CmdPractice
tree /f /a CmdPractice > folder-map.txt

Useful options and details

Options change how a command behaves. Add spaces exactly as shown, and use the command's built-in help when an option is unfamiliar.

A path containing spaces must be enclosed in double quotes, such as "C:\My Files".

  • /f includes filenames.
  • /a uses plain ASCII characters, useful in text files and terminals.
  • A path argument chooses the starting folder.

Tips and common mistakes

Check the current folder and read the command output before assuming an operation succeeded.

Practice with disposable files first. Commands that delete, overwrite, or stop a process may not offer an Undo button.

  • Do not confuse tree with File Explorer's interactive navigation.
  • Access-denied messages may appear for protected descendants.
  • A full user-profile or drive tree can expose private filenames if shared.

Safe practice

Create a temporary practice folder under your user profile so the examples cannot affect Windows system files.

After each command, inspect the result with dir or another read-only command before continuing.

  • Create two nested practice folders and files.
  • Compare plain tree with tree /f /a.
  • Save the map and inspect it with type.