Windows: How to Export a Directory Structure to a Text File( Directory Tree )
- Posted by
- Posted on August 19, 2025
- Computers, IT Support, Uncategorised, Windows
- No Comments.
When working with large projects, network drives, or simply organizing files, it’s often useful to generate a clear overview of your folder structure. Luckily, Windows includes a built-in command called tree
that makes this quick and easy.
In this guide, we’ll walk through how to print out your current folder and subfolders into a text document using Command Prompt.
Step 1: Open Command Prompt and Navigate to your Directory Location
-
Press Windows Key + R, type cmd, and press Enter.
-
By default, Command Prompt opens in your user folder (for example: C:\Users\YourName).
-
To move into the folder you want to document, use the cd (change directory) command.
Example:
cd C:\Projects\MyWork
-
If the folder path contains spaces, place the path in quotation marks.
Example:
cd "C:\My Projects\Work Files"
-
Once you’re in the correct folder, you can run the tree command. If you are already in the folder you want to document, you can skip changing directories and go straight to Step 2.
Step 2: Run the Tree Command
To generate a directory tree and save it to a text file, use the following command:
tree /f /a > directory_structure.txt
Here’s what each part means:
-
tree
→ Displays the folder structure in a tree format. -
/f
→ Includes the names of all files in each folder (remove this if you only want folders). -
/a
→ Uses standard ASCII characters instead of extended ones (better for text files). -
>
→ Redirects the output to a file. -
directory_structure.txt
→ The name of the file where the results will be saved.
Step 3: Open Your Text File
Once the command finishes running, you’ll see a new file called directory_structure.txt
in the same folder. Open it in Notepad, Word, or your preferred text editor to view the full folder and file layout.
Example
If you want to export the structure of a specific folder, such as C:\Projects
, you can run:
tree "C:\Projects" /f /a > project_structure.txt
This will generate a complete list of all folders and files under C:\Projects
and save them to project_structure.txt.
Example Text File
Folder PATH listing for volume Windows Volume serial number is 34A7-1C2D C:\PROJECTS │ README.txt │ ├───MyWork │ report.docx │ data.xlsx │ ├───SourceCode │ │ main.py │ │ utils.py │ │ │ └───Tests │ test_main.py │ └───Resources │ logo.png │ └───Docs manual.pdf reference.txt
Recent Posts
- Windows: How to Export a Directory Structure to a Text File( Directory Tree )
- Disable Smart Groups for Tabs in Firefox
- Upgrading to Ubuntu 24.04.02 – ” Oh no! Something went wrong “
- Microsoft Word – Use a VBA Macro to Delete All Images
- Powershell Script – Get the Most Recent User Login / Logoff Events
Archives
- August 2025
- July 2025
- June 2025
- January 2025
- January 2021
- May 2020
- February 2020
- December 2019
- August 2019
- January 2019
- July 2018
Categories
- Computers
- IT Support
- Lab
- Linux
- Management
- Microsoft Applications
- Networking
- Router
- Servers
- Switch
- Uncategorised
- Windows