Windows Explored

Everyday Windows Desktop Support, Advanced Troubleshooting & Other OS Tidbits

Printing Directory & File Lists In Windows 7

Posted by William Diaz on September 1, 2011


There is no native built-in way (still) in Windows to print a list of files displayed in Windows Explorer from Windows Explorer. For occasional use, though, there is a command line method which utilizes the DIR command and piping the results to a text file. To do this:

  • Open the command shell
  • Navigate to the directory you want to print a list of using the cd\ path command
  • Then use the Dir >listing.txt to pipe the results to a file
  • The file can be found in the directory you where the command was run
  • If access is denied, you will need to run the command shell with elevated rights, even if you are already an administrator

If you have user that is going to need to do this frequently, you can need to create a context menu option, which can be used for any folder, on the desktop or Explorer. If you had done this previously in Windows XP, the method is slightly different, since in Windows 7 you do not have the File Types tab available in the Folder Options menu of Explorer.

There is a Microsoft KB article on how to perform this for both operating systems, but the Windows 7 method does not seem to work as advertised … for me at least. I have modified the bat file so that directory list remains open in Notepad so it can be quickly printed in addition to creating a listing.txt file in %temp%.

The steps for doing this involve:

  • Opening Notepad and copying the the text below:
    @echo off
    dir %1 /a /-p /o:gn > “%temp%\Listing.txt”
    start notepad “%temp%\Listing.txt”
    exit
  • Save the file as Printdir.bat file in C:\Windows
  • Create a new text file and copy the following into it:
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\Directory\Shell]
    @=”none”
    [HKEY_CLASSES_ROOT\Directory\Shell\Print_Directory_Listing]
    @=”Print Directory Listing”
    [HKEY_CLASSES_ROOT\Directory\shell\Print_Directory_Listing\command]
    @=”Printdir.bat \”%1\””
    [HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory]
    “BrowserFlags”=dword:00000008
    [HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory\shell\Print_Directory_Listing]
    @=”Print Directory Listing”
    [HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory\shell\Print_Directory_Listing\command]
    @=”Printdir.bat \”%1\””
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]
    @=””
    [HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory]
    “EditFlags”=”000001d2”
  • Save the file as Win7PrintDir.reg (or whatever so long as it has a reg extension)

Afterwards, a right-click context menu option called Print_Directory_Listing will exist anytime you right-click a folder:

RCCntxtPrintDir

Notepad will launch and you can print the directory list from here. This is the same output if you were to use the DIR command from the command shell. Below is an example:

Volume in drive C has no label.
Volume Serial Number is EE4D-8AE5

Directory of C:\Users\username\Documents

07/20/2011 08:42 AM <DIR> .
07/20/2011 08:42 AM <DIR> ..
07/13/2011 10:59 AM <DIR> Any Video Converter
06/06/2011 10:49 AM <DIR> Favorites
06/27/2011 10:45 AM <JUNCTION> My Music [C:\Users\username\Music]
06/27/2011 10:45 AM <JUNCTION> My Pictures [C:\Users\username\Pictures]
07/19/2011 01:51 PM <DIR> My Received Files
06/27/2011 10:45 AM <JUNCTION> My Videos [C:\Users\username\Videos]
06/28/2011 04:05 PM <DIR> My Web Sites
06/28/2011 01:17 PM <DIR> My Weblog Posts
06/28/2011 09:22 AM <DIR> Network Monitor 3
06/27/2011 12:17 PM <DIR> NewToolBar
07/13/2011 03:12 PM <DIR> Snagit
06/28/2011 10:00 AM <DIR> Snagit Stamps
06/28/2011 04:35 PM 2 6-28-2011.txt
06/29/2011 02:41 PM 131 6-29-2011.txt
06/06/2011 11:48 AM 0 6-6-2011.txt
07/11/2011 09:06 PM 213 7-11-2011.txt
07/01/2011 05:16 PM 120 7-1-2011.txt
07/12/2011 03:47 PM 8 7-12-2011.txt
07/13/2011 09:18 AM 0 7-13-2011.txt
07/14/2011 12:29 PM 0 7-14-2011.txt
07/15/2011 11:57 AM 0 7-15-2011.txt
07/18/2011 05:11 PM 635 7-18-2011.txt
07/19/2011 08:18 AM 0 7-19-2011.txt
07/20/2011 03:51 PM 340 7-20-2011.txt
07/21/2011 08:29 AM 2,006 Default.rdp
06/06/2011 11:37 AM 402 desktop.ini
07/15/2011 08:20 AM 58,368 PTS 7-15-11.DOC
06/27/2011 11:05 AM 348 Windows Update Allow.reg
16 File(s) 62,573 bytes
14 Dir(s) 442,756,882,432 bytes free

If you wish to omit the folder and file details, you can add the /b switch to the second line of the bat file. The resulting output would then look like:

Any Video Converter
Favorites
My Music
My Pictures
My Received Files
My Videos
My Web Sites
My Weblog Posts
Network Monitor 3
NewToolBar
Snagit
Snagit Stamps
6-28-2011.txt
6-29-2011.txt
6-6-2011.txt
7-11-2011.txt
7-1-2011.txt
7-12-2011.txt
7-13-2011.txt
7-14-2011.txt
7-15-2011.txt
7-18-2011.txt
7-19-2011.txt
7-20-2011.txt
Default.rdp
desktop.ini
PTS 7-15-11.DOC
Windows Update Allow.reg

Note, this right-click menu option is for folders only. It does not apply to Libraries, e.g. Document or music libraries. If the user happens to have some screen capture software installed like SnagIt, then you can use the scrolling window feature to capture an image of a directory.

Advertisements

One Response to “Printing Directory & File Lists In Windows 7”

  1. binaryman said

    I rather not mess with the registry
    I like Directory Report
    http://www.file-utilities.com
    It can print more attributes than the DOS dir command

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: