Creating a Hierarchy Map of Your Hard Drive

by Allen Wyatt
(last updated December 14, 2015)

16

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

MORE FROM ALLEN

Checking for Matching Parentheses

There are lots of little "gotchas" that can make the difference between a finished document and a polished document. One ...

Discover More

Positive and Negative Colors in a Chart

When creating a line cart, the line can show values both positive and negative values. This tip explains how you can use ...

Discover More

Counting Employees in Classes

Excel is very good at counting things, even when those things need to meet specific criteria. This tip shows how you can ...

Discover More
More WindowsTips

Changing the Default Program for a File

Files are opened by programs depending upon the file's type. If you want to change this association so that a different ...

Discover More

Renaming Multiple Files at the Same Time

It's possible to rename multiple files at the same time, but the new names of the files may leave a bit to be desired. ...

Discover More

Stopping Windows from Creating Thumbs.db Files

Many times, the automatically created Thumbs.db file is more trouble than it's worth. If you want to stop Windows from ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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 one more than 6?

2015-12-18 16:49:37

Kevin

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


2015-12-18 11:27:40

PFL

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

PFL

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

David

Kevin,

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

Kevin

Having used the cduserskevin to get to
C:UsersKevin>
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

Suzanne

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

Tom

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


2015-12-14 20:51:09

Tom

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:

cd
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

Allen

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.

-Allen


2015-12-14 09:21:54

David

Lou,

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
C:UsersLousID

good luck!


2015-12-14 09:16:16

Skip

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

Anne

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
Subscribe

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.