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. ...


Engineering Calculations

Need to normalize your data in some way so that all your values are in a given format? This tip presents a number of ...

Discover More

Understanding Text Wrapping

Because you can put text into spreadsheet cells, it makes sense that not all that text could be displayed in a regular-sized ...

Discover More

Using a Portion of a Document's Filename in a Header

Headers and footers add a nice finishing touch to a document you plan on printing. You may want all sorts of information in a ...

Discover More
More WindowsTips

Creating a System Repair Disc

Doing a one-time create of a system repair disk can be worth its weight in gold if you find yourself unable to boot your ...

Discover More

Adding Locations to the Search Index

You can fine-tune Indexed Searches by adding locations to the search index. This tip tells you how.

Discover More

Pin Items to File Explorer's Quick Access View

You can improve your efficiency at navigating the file system by using the Quick Access view. This tip shows you how to pin ...

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. 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 three minus 2?

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.