How To Print A Directory Tree From Windows Explorer

 

 

Do you ever have a need to print the contents of a folder or entire directory tree in Windows XP or Vista?

If you do, Microsoft has a knowledge base article that will add "Print Directory" to Windows Explorer right click menu which will print the folder contents (or directory tree) that you are currently viewing.

But the problem with Microsoft's solution in Step 2 is that File Types \ Advanced option in Folder Options does not exist in Vista, and for XP you need to hack the registry to prevent the Search Companion window from opening when you try to open the folder using Windows Explorer.

FORGET THAT CRAP!

Fortunately there's an easier way to use this feature without messing around in the registry or searching all day for the Advanced button that doesn't exist. 

 

 

 

 

To do this, we'll use Step 1 as described in the knowledge base article, and create the batch file which will include the commands needed for printing.

Creating The Printdir Batch File

  • Open Notepad by clicking on Start \ Run and enter notepad in the Run dialog box and click OK.
  • Copy and paste the following text into Notepad:
@echo off
dir %1 /-p /o:gn > "%temp%\Listing"
start /w notepad /p "%temp%\Listing"
del "%temp%\Listing"
exit
  • Close Notepad and click Yes to save the changes.
  • In the Save As dialog box, copy and paste the following text in the File name: field(shown in below screen shot):

%windir%\Printdir.bat

  • Select All Files (*.*) in the Save as type: drop down field. Then Click Save.

winprintdirtree2.png

The Printdir.bat file has now been saved in the \Windows folder.

 

Next, we'll need create a shortcut to the Printdir.bat file in the Send To folder.

Create Printdir Shortcut

  • In Vista, click on Start \ Run and enter the following in the Run dialog box and click OK

%APPDATA%\Microsoft\Windows\SendTo

(NOTE: %APPDATA% is an environment variable that points to your user nameAppData\Roaming folder).

  • In XP, click on Start \ Run and enter the following in the Run dialog box and click OK(%USERPROFILE% is an environment variable that points to your use name Documents and Settings folder).

%USERPROFILE%\SendTo

  • In the SendTo folder, right click and select New \ Shortcut.
  • Type %windir%\Printdir.bat in the "Type the location of the item:" field and click Next.

winprintdirtree3.png

  • Type Print Directory Listing in the "Type a name for this shortcut" and click Finish.

winprintdirtree4.png

Now when you have the need to print a directory tree of folder contents from Windows Explorer, just right click and select Send To \ Print Directory Listing.

winprintdirtree5.png

Much better than mucking around in the registry!

Hey What About Printing From The Command Prompt?

Yea, if you like to work at the command prompt, you can just type printdir.bat (if you created the batch file) at the prompt or enter the following command:

dir /-p /o:gn > %temp%\Listing | start /w notepad /p %temp%\Listing

The command is similar to what we used in the Printdir.bat file, except were "piping" the command together with the "|" character (found above the Enter key and holding Shift down).

By using "|" (SHIFT+\ above Enter key), it allows you to execute two commands at once. Every time you execute, it will over write the file "Listing" so you don't need to worry about deleting it.

Cool!

Read 183 times
Dylan Austin

About:

Whenever I have a problem, I sing. Then I realize my voice is worse than my problem.

Top
We use cookies to improve our website. By continuing to use this website, you are giving consent to cookies being used. More details…