Creating a Hierarchy Map of Your Hard Drive

by Allen Wyatt
(last updated December 14, 2015)


As you start storing things on a hard drive, the structure of that drive can quickly become quite complex. You can end up with directories within directories within directories. If you want to create a "roadmap" that shows you the hierarchy of your hard drive, there's an easy way to do it.

  1. Display a command-prompt window. (In Windows 7 and Windows 10, click the Start button, type CMD, and press Enter. In Windows 8, press Win+C, click the Search icon, type CMD, and press Enter.)
  2. Type the following two command lines, pressing Enter at the end of each:
  3. cd \
    tree /a /f > mydrive.txt
  4. Close the command-prompt window.

Doesn't seem like much, does it? The first command line changes to the root directory for your hard drive. The second one generates a "tree" of your hard drive structure and stores the output in the file named mydrive.txt. This file was created in the root directory for the hard drive, and you can use Windows Explorer (Windows 7 and Windows 8) or File Explorer (Windows 10) to navigate to that directory and open the file.

If you don't want a hierarchy for your entire hard drive, you can limit what is generated by the TREE command. You do this by using command-prompt commands, in step 2, to navigate to the directory you want to use as the beginning point for the hierarchy. The mydrive.txt file is then created in that directory (instead of the root directory), and it contains only the hierarchy of the current directory and any subdirectories.

 This tip (10054) applies to Windows 7, 8, and 10.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Controlling Scroll Bars

Scroll bars are helpful if you have a document that won't fit entirely within the program window. Here's how to turn off ...

Discover More

Using Cross-References in Footnotes

Need to make a cross-reference from one footnote to another footnote? You can do it if you throw bookmarks into the mix, ...

Discover More

Using the Format Painter with Editing Restrictions in Place

Word allows you to apply protection to your documents that can affect which tools users can access. If you want to exempt ...

Discover More
More WindowsTips

Creating a System Image

A system image is a snapshot of your system disk as of a certain point in time. Should the need arise, you can restore ...

Discover More

Understanding ZIP Folders

Need to move a lot of information to someone else? The answer may be to store that information in a ZIP folder. Here's ...

Discover More

Creating a CD/DVD Archive

CDs and DVDs are good for creating archives of files you want to keep over the long term. They are a great way to back up ...

Discover More

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 0 + 1?

2015-12-18 16:49:37


Yes the spaces as noted in PFL were the missing ingredient.

2015-12-18 11:27:40


Speaking as a DOS user from the later 1980s through the 1990s, (I still do stuff in DOS) I feel the need to amplify my use of the word "correct".
Rather, it should be noted that there are many "correct" variations in the use of the parameters following the command.
AND, having to eat some crow, I just tried TREE /A/F and got the incorrect parameter message. Here is one command line example that does work.
TREE /A /F > C:USERSKEVINMYDRIVE.TXT (ENTER) note the space after /A.
Caps for clarity, but not necessary.
I am using the examples worded as Kevin would be using them on his machine.

Try TREE /? for help.

2015-12-18 11:05:39


Kevin, (and David)

tree/a/f>c:userskevinmydrive.txt (Enter)
is correct except that you MUST leave a space after the command "tree". This is a holdover from the DOS rules, where the separator between the Command and the parameter used by/with the command is a space. So
tree /a/f>c:userskevinmydrive.txt (Enter)
is correct (note the space).

2015-12-17 10:36:01



Try using the 2nd command, as shown in #2 of Allen's tip. That is, be cognizant of the spacing tree /a /f , and do NOT specify the location, just the file name, > mydrive.txt. DOS will create the file in the directory you run the command from ...

2015-12-17 06:20:03


Having used the cduserskevin to get to
I then enter
tree/a/f>c:userskevinmydrive.txt (Enter)
When I go to C:UsersKevin I do find a file myfile.txt however the only text in the file is "Parameter format not correct - /a/f"
Where is the error please?

2015-12-16 14:14:49


I tried this and got:
"Access denied"
I am not on a network, this is a personal home computer.
How can I access this?

2015-12-14 20:55:00


Got it to work. should have read the other comments first.

2015-12-14 20:51:09


I followed these directions and get 'access is denied'.

I am the administrator of the PC.

Any suggestions to get this to work?

2015-12-14 12:13:16

Scott Renz

To avoid access denied, output the file to a directory that you have write privilegs to:

tree /a /f >c:usersyour_namemydrive.txt

2015-12-14 11:07:32

David Smith

I am in Win7
The second command:
C:> tree /a /f > mydrive.txt
produces an error message:
"Access is denied."
Am I following your instructions correctly?
Thank you.

2015-12-14 10:23:32

Dave H.

Anne - Yes you are correct. This tip creates a simple text file. This file will not auto-update.

2015-12-14 09:21:59


Lou and Skip: I'm guessing that on your machines you may need to start a command-prompt window in Administrator mode. (Also, Skip, typing CMD is exactly what I say to do in step 1.)

Anne: No, it is not dynamic. This is an old DOS trick that produces the map as of the time it is executed.


2015-12-14 09:21:54



I got that message too.
It may be that your System Admin has protected access within the root directory. So skipping the command to change to the root directory, cd , might work ...

You may need to make sure you are in your directory within Users ... something like this maybe

good luck!

2015-12-14 09:16:16


In Win 10 I get the msg:

A require privilege is not held by this clients.

Also, in Win 10, to get the Command Prompt I had to type CMD into the Search the web and Windows block at the bottom right of the screen.

2015-12-14 07:47:23


I assume that this should be done every time one needs a snapshot of an hierarchical structure, meaning that it does not automatically update. Am I right?

2015-12-14 07:36:12

Lou Jones

When I tried this on my Win 8.1 machine, I got the message "Access is denied."

Newest Tips

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.