Windows

Get a better view of the Windows XP Tree command with Word

Using the Tree command to research the folders on your Windows XP hard disk can give you results that are too fast for your eye to catch. Greg Shultz explains how to use Word to view a Tree you can read in detail and at your own pace.

To find out how many folders there are on your Microsoft Windows XP hard disk, you can open a Command Prompt and use the Tree command. You'll get a very nice looking graphical tree structure showing all the folders on your hard disk. The only problem is that the display will scroll by your screen so fast and exceed the buffer size, so you'll never be able to see it.

Instead, try using the old MS-DOS pipe to funnel the output of the Tree command to a Rich Text Format (RTF) file. You can then import that RTF file into a specially formatted Word document and have the same graphical tree structure, showing all the folders on your hard disk, in an easy to read format. Here's how:

  1. Open a Command Prompt window.
  2. Use the CD \ command to access the root folder.
  3. Type Tree > Tree.rtf
  4. Close the Command Prompt window.
  5. Launch Word and open a new document.
  6. Go to File | Page Setup.
  7. In the Page Setup dialog box, choose the Landscape Orientation, and set the left and right margins to zero.
  8. Click OK and click the Ignore button in the margins warning dialog box.
  9. Go to Insert | File.
  10. In the Insert File dialog box, locate the Tree.rtf file and click the Insert button.
  11. In the File Conversion dialog box, select the MS-DOS option and click OK.

You can save the document and then scroll through the graphical tree structure showing all the folders on your hard disk.

This blog post is also available in the PDF format in a TechRepublic Download.

Note: This tip applies to both Windows XP Home and Windows XP Professional. Editor's note: The file can be viewed by any word processor or text editor with RTF capability.

Miss a tip?

Check out the Windows XP archive, and catch up on our most recent Windows XP tips.

Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

71 comments
mw00110011
mw00110011

The ">" symbol is the Redirect command, not the pipe command. Pipe is "|" which I believe performs a different function by sending output of the first command to a second command - requiring actual, executable commands on both sides of the pipe operator. It is always nice to find a useful nugget from the 'good-old-days' of computers! The TREE helps put everything in perspective - something that seems to be lost (to me anyway) in Vista's Explorer model. An interesting challenge would be to write a Word VBA script (stored in the tree.rtf file) to traverse this 'tree' and collect data such as folder size that could be tacked on to the end of each node.

philrunninger
philrunninger

Why use a word processor for this sort of thing? I like the notepad idea: redirect to a .txt file, and let Windows file associations take it from there. Better yet, use vim. Start the editor, then type this command (without the arrows) >>---> :r! tree C:\path /a

deICERAY
deICERAY

I didn't read all the comments, but anytime you give MS Word instructions be SURE to include what old version you are working in, because baby, it ain't that way in 2007!

msdaug
msdaug

> is not the pipe command. That is simply standard out redirection. The pipe command is | which allows you to funnel the output of the first command into another application.

BobbiM10
BobbiM10

Use the free version of Treesize from Jam Software. Much better result than from DOS. Go to jam-sofware.com and click on Windows Freeware. They also have a pro version for sale.

Photogenic Memory
Photogenic Memory

You can see the information descend in it's directory path but the formatting into .rtf or .doc looks so bizzare. It looks clearer in a .txt file. However the info is preserved better if your use "edit" or "type" to view it in the command line.

plepkowski
plepkowski

The shareware file viewer Total Commander provides an interactive searchable tree window with Alt+F11. See www.ghisler.com

fixmypcmike
fixmypcmike

OK. after trying to find "file conversion", (I used "Help") there is no dialog window that says "MS-DOS". All that this file shows are funny-looking "A"s and maybe a few directories or so. I am using Word 2003. There should heve been a note posted about how to get the "file conversion" to work and a mention that it does not apply to Word 2003.

Data Ninja
Data Ninja

There's also a program that will allow you to right-click on the drive/directory of choice and select the option, then whether you want to send it to a file, on-screen and include filenames or not. I think the current version is 1.1 and can be found out in the wild. It's an amazing program. I found it here: http://198.252.9.209/files/index.php?path=apps

dawgit
dawgit

Sorry, I had to do that. Good refresher, thanks. Items like that remind me how much I've forgotten. -d

Coriell
Coriell

This also works in VISTA Word 2007 Tree command print out 1. Open a Command Prompt window. 2. Use the CD \ command to access the root folder. 3. Type Tree > Tree.rtf 4. Close the Command Prompt window. 5. Launch Word and open a new document 6. Go to Explore | ???user??? Open File > Tree.rtf 7. In the File Conversion dialog box, select the MS-DOS option and click OK 8. Save file. Also work for all drives. see command help tree

pal526
pal526

Open a Command Prompt window. Use the CD\ command to access the root folder. Type Tree > Tree.rtf Close the Command Prompt window. Launch Word Click on Page Layout Click on Margins (This resides in Page Setup),then custom Margins and set the left and right margins to zero. Click OK and click the Ignore button in the margins warning dialog box. Within Page Layout click on orientation (This also resides in Page Setup) then click on landscape Click on Insert | Object | Text from file. Locate the Tree.rtf file (This should be under the root or C:\) and click the Insert button. In the File Conversion dialog box, select the MS-DOS option and click OK.

pal526
pal526

This is how to do it with word 2007. 1. Open a Command Prompt window. 2. Use the CD \ command to access the root folder. 3. Type Tree > Tree.rtf 4. Close the Command Prompt window. 5. Launch Word 6. Click on Page Layout 7. Click on Margins (This resides in Page Setup),then custom Margins and set the left and right margins to zero. 8. Click OK and click the Ignore button in the margins warning dialog box. 9. Within Page Layout click on orientation (This also resides in Page Setup) then click on landscape 10. Click on Insert | Object | Text from file. 11. Locate the Tree.rtf file (This should be under the root or C:\) and click the Insert button. 12. In the File Conversion dialog box, select the MS-DOS option and click OK.

Mark W. Kaelin
Mark W. Kaelin

Thanks for the additional command line and batch file suggestions. It brings back fond memories of a bygone era.

edjon2000
edjon2000

In addition to the above you can slightly modify the command to tree /F > tree.rtf

philip_doughty
philip_doughty

This is a handy trick to have - I've tried it before.I'm still looking for a combo of tree & directory listing with selectable details printed to an rtf. Surley it's not much to ask - I only want it all :)

philip_doughty
philip_doughty

Is there such a command that will do this but to also include the files & basic details from within each directory?

melekali
melekali

(your solution)...was posted several times already, even informing the uninitiated how to open the document immediately upon save.

melekali
melekali

...no problems in Word 07. I chose to save in rtf format. Would have been one less step if I opened in docx format...

techwriter
techwriter

I know the interface is different in Word 07, but- What fails? Do you not have the option to select character set?

techwriter
techwriter

Someone already pointed this out for Word 03, but it applies to '97 as well. Under Tools>Options (General tab) there's a checkmark for "confirm conversions" (wording might vary between versions?) If you don't have this checked, Word just sucks the text in however- and you get funny stuff instead of graphics. FWIW: OpenOffice (2.4.1) dows a great job of this.

doug.cronshaw@baesystems
doug.cronshaw@baesystems

Doing HELP TREE at the CMD prompt will show you that you can use the /A qualifier on the TREE command to render TREE's output into pure ASCII text. All those funny-looking "A"s - technically these are A-tilde and A-diaeresis characters - and superscript-3s will then be replaced by sensible plain text. [You'll still need to have your Word Open File dialogue box characteristics set to open Rich Text files to get it to automatically open the now plain text format file, but that should be part of the default settings for Word 2003.]

edjon2000
edjon2000

I overcame the problem by modifying the word options as follows :- Go to Tools>Options and select the General tab, Select the Confirm conversion at Open checkbox, this will force Word to open a Convert file dialog box, select Encoded Text and click Ok, this will open a file conversion dialog box in there, select the MS-DOS Radio button and you will be good to go

edjon2000
edjon2000

I overcame the problem by modifying the word options as follows :- Go to Tools>Options and select the General tab, Select the Confirm conversion at Open checkbox, this will force Word to open a Convert file dialog box, select Encoded Text and click Ok, this will open a file conversion dialog box in there, select the MS-DOS Radio button and you will be good to go

edjon2000
edjon2000

I overcame the problem by modifying the word options as follows :- Go to Tools>Options and select the General tab, Select the Confirm conversion at Open checkbox, this will force Word to open a Convert file dialog box, select Encoded Text and click Ok, this will open a file conversion dialog box in there, select the MS-DOS Radio button and you will be good to go

edjon2000
edjon2000

I overcame the problem by modifying the word options as follows :- Go to Tools>Options and select the General tab, Select the Confirm conversion at Open checkbox, this will force Word to open a Convert file dialog box, select Encoded Text and click Ok, this will open a file conversion dialog box in there, select the MS-DOS Radio button and you will be good to go

info
info

Works fine in 2003. Just did it. Thanks guys, great tip!!!

Judy~in~Alaska
Judy~in~Alaska

If you don't know how to get into Dos.. it is a fair guess that you shouldn't go there. Many many things can go wrong in there without a little training.. mine came from leaning over a geek.. going.. whatcha doing.. why are you doing that..ahhh memmorys.....

tjreaka
tjreaka

I am new to Word 2007, but I tend to be very intuitive: the procedure you describe is exactly the one I followed without directions, and it works perfectly every time. I am ROFLMAO at some of the silly arguing going on over this simple but effective procedure....kinda makes you wonder what happened to the "people skills" classes...

vin.reilly
vin.reilly

1.Open a Command Prompt window. 2.Use the CD \ command to access the root folder. 3.Type Tree > Tree.rtf 4.Close the Command Prompt window. 5.Launch OpenOffice Writer and open a new document. 6.Go to Format | Page. 7.In the Page Style dialog box's Page tab, choose the Landscape radio button, and set the left and right margins to zero. 8.Click OK and click the Yes button in the margins warning dialog box. 9.Go to Insert | File. 10.In the Insert File dialog box, locate the Tree.rtf file (which the Tree command as coded above placed in C:\) and click the Insert button. 11.In the ASCII Filter Options dialog box, select the Western Europe (DOS/OS2-850/International) Character Set and click OK.

emoore
emoore

Just type into a command window tree |more Works in XP and Vista

melekali
melekali

...that remark. :o) Happy command prompt computing...

fsdondo
fsdondo

anyway to make this work in vista? I only get access denied when I input tree > tree.rtf... thanks

yordan.georgiev
yordan.georgiev

Start - Run - copy paste: cmd /c "tree C:\ >tree.rtf&start /max winword.exe tree.rft"

MarkB29681
MarkB29681

It may not be desirable to create tree.rtf (e.g. you don't have Word installed, etc.). You can get the same information in a text-only format using this command line: tree /a > tree.txt then view it in notepad, even edit tree.txt if you prefer.

johncymru
johncymru

To add the file names to the Tree list just add the /f switch, i.e. tree /f > tree.rtf or tree /f /a > tree.txt if like me, you prefer opening the resultant tree in notepad. Note, though this only adds file names and doesn't add details like size etc.

r_p_roberts
r_p_roberts

Very helpful! Been using the ascii option because I couldn't figure out why Word wouldn't ask me how to convert the normal output. (Had no problem with WordPerfect - but WP is verboten at work). Thanks!

edjon2000
edjon2000

I am sorry about the repeated posts when I originally posted the reply I got a page nopt found message three times please could the moderator remove the extra replies

john.rodgers
john.rodgers

I have tried this with and it "inserts" great into Word 2003 except for the garbage. There are characters where the spaces are. How do I get rid of these?

jgw321
jgw321

He was not asking how to get in to DOS but where to find the MS-Dos format option within word. He said he did not have a Conversion entry on the File Menu within Word. This is the fault of the original poster of this tip, who assumed incorrectly that everyone had identical installations of Word to him. He should have pointed out the need to instal the conversion package if it was not installed during the original Word installation. People posting tips for non experts to follow should make sure their instructions are correct for all versions of the software. JG

info
info

Got my first PC before the IBM came out. Anyone remember cp/s? You had to know the commands or you got nowhere! Very quickly!

pjboyles
pjboyles

Note that in Vista, you do not have access to the root of the partition by default. Just create a subdirectoty and use the subdirectory.

Dumphrey
Dumphrey

open the run/start box and type in cmd, BUT press ctrl and shift while you hit enter, that should give you a UAC prompt for cmd. Try in that window to see if it works.

gdunger
gdunger

The Editor's note: "The file can be viewed by any word processor or text editor with RTF capability." and the suggestion that you use tree > tree.txt indicate a fundamental misunderstanding about Windows. Windows does not care what you call this file - you could call it tree.mp3 - it's always the same extended ASCII text. The redirection used no more makes an RTF file than it makes an mp3 file. The extension used will effect double-clicking. Your default mp3 player will complain about the mp3 file, and if you do not have Word, the default Wordpad will open the RTF file but does not have Word's ability to change the handling of extended ASCII characters.

mikemajor3
mikemajor3

yeah, I remember StereoShell; my fave in that day was Peter Norton's Commander...I used QuarterDeck's memory manager... I worked a lot with both CP/M and ZCP/M, which had the command wheel..you could actually restrict which commands external users could access, which as a BBS board writer was waaaay useful... makes me think; I haven't cracked open a project file in like six or seven years... guess I'm getting lazy...last stuff I did was some patches on somebody's errant webpages. Far cry from the (freebie) all-nighters chasing a bug you found on the system you wrote, on the machine you built...

mirossmac2
mirossmac2

CP/M was what they ripped off - sorry - built on for DOS 1.0 ... and there was PCTools 1 ... Quarterdeck, which was soooo like Windows 1.0 ... and assembly language on the Zilog Z80 chip ... the packages from the Public Domain Software Library ... we could program down on the bare metal back then. Sometimes I wake up sweating ...

jsmith.rmga
jsmith.rmga

I have fond memories of using a cool DOS file manager called StereoShell that showed the tree structure in two "windows"; you could do file or directory searches, copy, move, etc. Anyone else?

Data Ninja
Data Ninja

You should be also be able to run it with full privileges by using right-click, 'run as' administrator on the 'command prompt' shortcut. Probably more work than the ctrl+shift method though...

tjreaka
tjreaka

Look folks, I am not a programmer: I build custom PCs, and am the local PC guru for the entire neighborhood. I had no problem following the directions in both methods of this procedure and getting the desired results. Seems to me that some of these posts amount to engaging in a pissing contest over nothing at all. Choose what works for you and get over the rest. Personally, I found the post from Northampton, MA very helpful and enlightening.

gdunger
gdunger

My apologies if I offended you in some way. I thought the original post needed clarification for those who misconstrued the role of .RTF in the post and subsequent posts bear this out.

jgw321
jgw321

> 'and the suggestion that you use "tree > tree.txt" indicate a fundamental misunderstanding about Windows.' No it indicates that you did not understand what was written. He did not say "tree > tree.txt" but "tree /a > tree.txt". I suggest you go away and look up the tree command before you witter on about file extensions, which is not really relevant to his post. The "/a" is needed as Notepad does not have the conversion facilities that SOME (but not all) versions of Word have. The .txt is only to allow it to be easily opened in notepad (or other text editor), just the .rtf makes it easier to open the file in word. If you want to be perverse you could name the files .mp3 in both cases, it would still work, but just not so easu to open the files with the right program. JG

dsjjfg
dsjjfg

I was going to post the comment about "it's not really RTF" because the original article suggests that it is. He was really just pointing out the fact that it does not, and backed it up with an authoritative (and completely correct) explanation -- knowledge that goes beyond this particular example. Sorry, I can't be critical of that. I'm sure there are some less-knowledgeable readers who appreciate it.

brent
brent

Of course he said .rtf so that it's easier to open. Your post shows that you just like to be heard, nothing more. I'm sure everyone reading this post knows what extensions are and their purpose. Your post seems to make it appear this is new to you and you are trying to show off your magnificent knowledge.