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:
dir %1 /-p /o:gn > "%temp%\Listing"
start /w notepad /p "%temp%\Listing"
- 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):
- Select All Files (*.*) in the Save as type: drop down field. Then Click Save.
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
(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).
- 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.
- Type Print Directory Listing in the "Type a name for this shortcut" and click Finish.
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.
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.