Windows optimize

Import the results of Windows XP's Tree command into Word

Using the Tree command to research your folders on your Windows XP hard disk can give you results fast—too fast for your eye to catch. Here's how to use Word to create a Tree you can read in detail and at your own pace.

To find out how many folders there are on your 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 an RTF (Rich Text Format) 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 a document. 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 0.
  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.

Note: This tip applies to both Windows XP Home and Windows XP Professional.

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.

37 comments
magicbbs
magicbbs

ALL I got where pluses and "|" and minus signs to make the tree ... mmmm I wonder if it would work BETTER now that I have linedraw installed???? Oh, well I can sleep tomorrow night !!!

magicbbs
magicbbs

Thanks JackOfAllTech I just downloaded linedraw and it looks BEEEUTIFUL!! had to sign up and let you know!! Thanks for my NEW Christmas.toy!!

DanLM
DanLM

I didn't know this command, and even though it has been pointed out by other posters here that when loaded to a txt file it will show funky characters. I am sure I can find another utility to convert those characters... I'll just create a bat file for everything so I can use it when ever needed. Nice way to get a print of your tree structure. Hmm, buried my head in Unix so long that I never took the time to keep up on the powers of dos commands. Again, thank you. Dan

sethlev
sethlev

Hidden folders will not display, so it's value can be limited. Does anyone know how to also display hidden folders?

CharlieSpencer
CharlieSpencer

http://www.pcmag.com/article2/0,1759,10879,00.asp It doesn't list 2000 or XP as compatible, but it does work with them. This freebie adds options to the right-click menu in Explorer. It will output the directory structure, with or without individual file names, to either a printer or a file. Why bother playing around with Word?

pinroot
pinroot

"Instead, try using the old MS-DOS pipe to funnel the output of the Tree command ... Type Tree > Tree.rtf " That's actually output redirection. A pipe would be something more like: tree|more The output from "tree" gets piped through "more" and output pauses at the end of each screenful of info until you hit the space key.

GBJim
GBJim

This is VERY timely! I have been looking for a program to do exactly this, but this is perfect and a lot quicker. Is there a way to include all of the files in the folders? Possibly the VERBOSE command? Thanks for you help, Jim

Pseudo8
Pseudo8

Mine was displayed with Japanese characters (??) You can also get a graphical representation of folders with the opensource program freemind (still in beta but works like a charm) at freemind.sourceforge.net After installing select File, Import, Folder Structure

Neon Samurai
Neon Samurai

1. win+r 2. cmd [enter] 3. tree > tmp.txt 4. start tmp.txt or 4. notepad tmp.txt saves you requiring Office installed or leaving the prompt to start a new program.

GreyTech
GreyTech

for %a in (c d e f g) do tree /f %a:\>>tree.rtf Just remember with the /f option the file may run into thousands of pages (2700 for me) Because tree and other things may need admin rights if the system is really locked down I always have a shortcut on the desktop with the target set as: %windir%\system32\runas.exe /user:administrator cmd That way I run normally without admin rights. You can run explorer or control from the command window if you need to.

ddmcp2000
ddmcp2000

But it CAN be done with this line: dir c: /s >c:\temp.rtf That will get all the files, including hidden ones. Your output will be in categories, alphabetically, and the file will be pretty huge. Mine was 3.8MB.

Lost Cause?
Lost Cause?

I went looking for TreePrint at PC Mag site. It's not free any more...

justme
justme

use the command tree /f /a > tmp.txt This will give all files, as well as ascii readable characters. Check syntax for any dos command by entering the command followed by "?" such as "tree ?".

ddmcp2000
ddmcp2000

See above. Since I can't delete, I just have to edit my previous post... I should really read EVERYTHING :)

daarka
daarka

Remember the DOS command DIR? use DIR /S> dirs.rtf (Step 3 of the published notes) to create file dirs.rtf with all of the file names. TREE /F (already mentioned) will also list file names, but DIR has the advantage of including file sizes and other information. try HELP DIR for his other options.

mwlahn.subscriptions
mwlahn.subscriptions

Just do a "tree /?" to see the options, but the one you are looking for is /F. That one lists all the files in the directories. From my current workstation the tree /? shows... C>tree /? Graphically displays the folder structure of a drive or path. TREE [drive:][path] [/F] [/A] /F Display the names of the files in each folder. /A Use ASCII instead of extended characters.

Neon Samurai
Neon Samurai

It's actually a native verbos program, the ">" redirect is what's hiding the output by routing it to a file. There are a few other programs listed here though I've also added JDirPrinter (folders, files, file attributes and sizes) and AccessTree (my preference is Jdir, AT is my backup).

deICERAY
deICERAY

Print folders, Z File inventory, and other freeware also do the job, some will allow extensive customization, check out file lister programs elsewhere, like the downloads here and tucows, for a start.

Neon Samurai
Neon Samurai

Word initially tried to open the .rtf with Japanese character set also, select the Dos radio button one to the left and it opens clean. For GUI programs, JDirPrinter works well for me; if you got 20 seconds to get a drive map and get out, it'll do it. AccessTree is a similar program I keep handy but rarely use. Both run clean off a flashdrive so you can add them to your Tech toolbag.

labasa_1
labasa_1

All the entries were having leading AAAs making it hard to read

barry
barry

Why not just open it directly into Word? I just located the file by changing the file type to any Word document, and then opened the file. I had a choice of windows, text or japanese format, and although the Japanese format seemed fine, I changed to Ascii text, and the file is clear and easy to read.

deICERAY
deICERAY

"Screens ? ? ????NetInfo ? ? ????Windows Media ? ? ????Windows Media Bonus Pack " This is an example from what my notepad file looked like, not really usable without a LOT of fixing.

DotJock
DotJock

Apparently requires admin rights. Without it, all I get is ?access denied.?

Neon Samurai
Neon Samurai

I thought I was being so smart many years ago when I first learned about dos Attrib until my dad walked up to the family computer and typed "dir /ah /s"

CharlieSpencer
CharlieSpencer

I see what you mean. I pulled it down years ago. I checked the URL but didn't actually click the "Download" link. I didn't see the payment screen.

justme
justme

goofed and left off part of the syntax. to see parameters for any dos command, use the slash before the question mark.

jruby
jruby

You would think somebody would Read The Fine Online Help before asking that question. Tree /? -- What a concept... ;->

Greg Shultz
Greg Shultz

If you follow the instructions in the orignal tip, you'll have a nice looking display of all the folders on your hard disk. ;-)

JackOfAllTech
JackOfAllTech

Just configure notepad (or whatever editor you're using) to use MS Line Draw or Courier New. Ralph edited for close paren.

digital_world2001
digital_world2001

i hink you have missed MS-Dos option after inserting the file tree.

sethlev
sethlev

Try using the /A switch. i.e., TREE /A > TREE.RTF This uses the straight ASCII set and looks fine. Good luck!

mwlahn.subscriptions
mwlahn.subscriptions

Make sure when you do open the RTF file that you use the MS-DOS file conversion formatting. That will give you the correct format. If you use Windows(Default) or Japanese (Shift-JIS), as my current machine wanted to default to, your tree will look like garbage. Another alternative is to use TREE /A to use ASCII characters instead of the the MS-DOS Extended characters. Not as pretty, but it works!

Neon Samurai
Neon Samurai

I see your point. The Dos character set does not cross over directly to GUI character set. I might argue that that's yet another user-unfriendly bug in windows but this isn't that discussion. Regardless of cause, .wri and .rtf retain that pretty view but hidden behind the GUI unfriendly characters. My goal was to avoid touching the mouse just to open the file after. I belive the article recommended running tree > tmp.rtf then opening a program and opening the file throguh the dialogue. That's just way too much mucking about with the misserable mouse when it's not needed. (side: double ">>" will append rather than overwrite) Note: the tmp.txt file is not damaged in any way, if open it in Word manually or by renaming to ".rtf" and double clikcing (start tmp.rtf) word will open and convert to display the line characters properly. These are probably now exacly like the recommendation except for avoiding the mouse. 1. win+r 2. tree > tmp.rtf 3. start tmp.rtf I think Wordpad may open if Office is not installed and your still opening through Start.exe so you don't need to slow down by using the mouse. Alternatively, if you remain in the Dos environment completely. 1. win+r 2. tree > tmp.txt 3. edit tmp.txt I've also used Edit often to conver Unix ascii files since it'll properly open them then naturally save them as a Dos/Windows friendly text.

Neon Samurai
Neon Samurai

On one hand, it's worth noting that your machine is locked down properly with restricted rights. On the other hand.. booo.. admin rights to redirect a directory output to file. I can't tell if it would be restrictions against tree.exe or not. Notepad and Start are both user level. Thanks for the bug report though. I hadn't had that issue but it's good to know it exists.

justme
justme

use the command tree /a > tmp.txt for readability