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:
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> . |
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.
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