On Windows 11 and Windows 10, open Command Prompt and run tree "C:\Path\To\Folder" /f /a > "%USERPROFILE%\folder-tree.txt", replacing the example path with the folder you want to inventory. The command saves its folder hierarchy and filenames to a text file in your user profile. /f includes files, and /a uses plain-text characters for the branches.

A Windows desktop shows a project folder and its file tree in File Explorer, Notepad, and Command Prompt. Before you export the folder tree​

Choose the folder you want to list and a separate location for the output file. The instructions below use %USERPROFILE%\folder-tree.txt as the destination; %USERPROFILE% expands to your Windows user profile folder, such as C:\Users\Alex.

  • You need permission to read the source folder and its contents, and to create a file in the destination.
  • An ordinary Command Prompt is sufficient for folders your account can access. You do not need to install anything or restart Windows.
  • Keep the output outside the folder being listed when possible. Otherwise, the newly created text file may appear in its own inventory.
  • The result is a list of names and hierarchy, not a backup. It does not copy the files or their contents.
  • A large folder or drive can take longer than a few minutes and produce a large text file. Start with a smaller folder if you want to check the format first.

The procedure is the same on Windows 10 and Windows 11. Microsoft’s standard support for Windows 10 ended on October 14, 2025; eligible devices enrolled in Extended Security Updates can continue to receive certain security updates.

Export a folder and its filenames​

  1. Find the source folder’s path. Open File Explorer and navigate into the folder you want to list. Select the address bar so it shows the folder’s full path. You can copy that path with Ctrl+C.
    For example, a path might look like C:\Users\Alex\Documents\Projects. Use the actual path shown on your PC rather than typing this example.
  2. Open Command Prompt. On either Windows 11 or Windows 10, open Start, type Command Prompt, and select Command Prompt. If it opens in a Windows Terminal window, make sure the tab is running Command Prompt rather than PowerShell.
  3. Prepare the command. Use the following as a template:
    tree "C:\Path\To\Folder" /f /a > "%USERPROFILE%\folder-tree.txt"
    Replace C:\Path\To\Folder with the path you copied in step 1. Leave the double quotation marks around the path, especially if it contains spaces. Keep the quotation marks around the destination too.
    For example, the command for the sample Projects folder would be:
    tree "C:\Users\Alex\Documents\Projects" /f /a > "%USERPROFILE%\folder-tree.txt"
    The first quoted path is the source folder. The quoted path after > is the output text file. Change the output filename or location if you prefer, but make sure its parent folder already exists.
  4. Check the destination before running the command. The > operator replaces the contents of an existing file at that exact output path without asking. Choose a new filename or back up the existing file first. In particular, do not point the output at a document you need to keep.
  5. Press Enter and wait for the prompt to return. The listing is redirected to the file, so you should not expect to see the tree printed in the Command Prompt window. Error messages may still appear there; read them before closing the window.
    If the scan is taking too long, press Ctrl+C. The output file may then contain only a partial listing.

Open and check the result​

  1. In the same Command Prompt window, open the output in Notepad:
    notepad "%USERPROFILE%\folder-tree.txt"
    If you chose a different output path, use that path instead.
  2. Check that the listing starts at the intended folder and contains some recognizable subfolders and filenames. Depending on the drive and folder, the output can also include volume or folder information near the beginning.
  3. Compare a few entries with File Explorer, including at least one file in a subfolder. Use Ctrl+F in Notepad to search for a filename you expect to find.
  4. Review the Command Prompt window for errors. The existence of a text file alone does not prove that every folder was accessible or that the scan finished. If you interrupted the command or saw an access error, treat the listing as potentially incomplete.
  5. Before sharing the file, review it for sensitive names. Even without file contents, a tree can reveal usernames, project names, client names or other information you may not want to disclose.

The text file is a snapshot of the names at the time of the scan. It will not update when files are added, moved or deleted; rerun the command to make a fresh listing.

Choose folders only or change the output​

The switches control what tree displays. They can be used together or independently:

  • /f includes filenames in each folder. Without it, the output shows the folder hierarchy without the file names.
  • /a uses text characters for the branch lines instead of graphic line-drawing characters. This often makes the layout easier to share in plain text.
  • > sends the listing to a file instead of displaying the normal output in the window.

For a folders-only listing, omit /f. This example saves to a different filename so it does not replace the earlier file:

tree "C:\Users\Alex\Documents\Projects" /a > "%USERPROFILE%\folders-only.txt"

Replace the example source path before running it. Open the result with:

notepad "%USERPROFILE%\folders-only.txt"

You can also omit /a if you prefer the graphic branch characters. If those characters display incorrectly in a text editor or after sharing, create another copy with /a.

Important: /a changes the characters used for the tree’s connecting lines. It does not turn non-English filenames into ASCII or guarantee that every filename will be encoded correctly in every application.

Export from the current folder instead​

If Command Prompt is already working in the folder you want to list, you can omit the source path. Microsoft documents that tree then starts at the current directory on the current drive.

  1. Check the current directory by entering:
    cd
  2. Confirm that the displayed path is the folder you intend to inventory. If it is not, use the full-path method above instead of relying on the current directory.
  3. After checking that the destination will not overwrite a file you need, run:
    tree /f /a > "%USERPROFILE%\folder-tree.txt"
  4. Wait for the prompt to return, then open and check the file as described above.

This shortcut is useful when the prompt is already in the right place. The full-path method is less ambiguous if you are unsure which directory is current.

Troubleshoot missing, incomplete or unreadable output​

The text file is empty or not where expected​

First, look at the exact destination after > in your command. %USERPROFILE%\folder-tree.txt is in your user profile folder; it is not necessarily on the Desktop or in Documents.

Run this command to open the intended file:

notepad "%USERPROFILE%\folder-tree.txt"

If Notepad cannot find it, check the Command Prompt window for an error. The destination’s parent folder must exist, and your account must be able to write there. If you changed the destination, try an existing writable folder and a new filename.

A file can be created or replaced even when the source path is wrong or the listing fails. Check the source path separately in File Explorer, correct it, and rerun the command. Do not assume an empty file means the source folder is empty.

A folder or file is missing​

Check that you included /f if you expected filenames. Without it, tree lists the directory structure but not the files in each directory.

Next, confirm that you scanned the correct starting folder. Open the source path in File Explorer and compare it with the path in your command. If a particular subfolder is in question, run tree against that subfolder as a separate test, using a new output filename so you preserve the first result.

Permissions and an interrupted scan can also make a listing incomplete. If the folder belongs to another user or is managed by an organization, ask the owner or IT administrator for appropriate access rather than changing permissions solely to make the inventory work.

Access errors appear in Command Prompt​

The normal > redirection captures standard output; some error messages can still appear in the Command Prompt window. Note the message and the path involved. Check that the drive or network location is available and that your account can open the relevant folder in File Explorer.

For a diagnostic copy that combines standard output and standard error in one file, use a new filename:

tree "C:\Path\To\Folder" /f /a > "%USERPROFILE%\tree-diagnostic.txt" 2>&1

Replace the source path before running it. Open tree-diagnostic.txt afterward and look for messages as well as the listing. Combining the streams helps capture errors, but it does not grant access or make an incomplete scan complete.

Branches or filenames look wrong​

If the branches use unexpected symbols, rerun the command with /a and check the new file. If the branches look fine but accented or non-Latin filenames are wrong, the issue may instead involve character encoding. Compare the names with File Explorer and try opening the saved file in a text editor that lets you choose an encoding.

Do not rely on a listing with corrupted names as a definitive inventory. If the correct names cannot be recovered in the editor, keep the original files unchanged and seek help with the encoding used by the command-line environment and the receiving application.

You overwrote an existing output file​

Stop rerunning the command against that filename. Check whether you have a backup or an earlier version available through your organization’s recovery tools or your own backup system. The tree command cannot restore the previous contents of a file overwritten by >.

For future exports, use a distinct destination name, such as folder-tree-2.txt, and confirm the full path before pressing Enter.