Send Listing of Directory or Folder To Notepad For Easy Printing

   Posted January 26, 2004 by David Kirk in Windows

Windows does not have an easy way to print out the contents of a directory or folder. This shortcut makes the task simple.

Often I need to print or email somebody a listing of a folder’s contents. Windows does not have an easy way to do this.

The creation of this file will make this task very simple.

1. Open Notepad
2. Copy and paste the following text:

@echo off
if EXIST %1 goto start
echo Drag and drop any file onto this program to grab its parent directory listing.
goto end
echo "%~dp1"
dir "%~dp1" > dir.txt || pause
start dir.txt

3. Under the File menu select Save as.
4. As you want to save this to your desktop, browse to the appropriate location.
5. Under filename type dirlist.cmd
6. Under Save as type select All Files.
7. Click OK.

A file called dirlist.cmd should be created on your desktop. Clicking this file will just give you the echo message and not do anything productive.

To use your new tool, drag any file onto this newly created item on your desktop. The directory contents of that file’s folder will be opened in Notepad.

For example, to print out a listing of my toolbar directory, I would navigate to my toolbar directory and drag any file in the toolbar directory to the dirlist.cmd file.

This produces the following:

    Volume in drive C is ALEX
    Volume Serial Number is 3943-16E3

    Directory of C:\Toolbar

    10/31/2001 10:33 PM

    10/31/2001 10:33 PM ..
    11/18/2003 09:23 PM 1,127 ALEX (C).lnk
    01/20/2002 12:18 PM 1,122 WINSLOW (D).lnk
    01/27/2002 02:26 PM 1,142 CD Drive.lnk
    11/01/2001 06:55 PM 362 Shortcut to My Pictures.lnk
    11/01/2001 06:55 PM 347 Shortcut to My Music.lnk
    11/01/2001 06:58 PM 252 Shortcut to My Documents.lnk
    6 File(s) 4,352 bytes
    2 Dir(s) 12,076,679,168 bytes free

I do not know where I first saw code similar to this, but hats off to the original author. The only trick is to remember to drag any file from the folder in question onto your dirlist.cmd file.


About David Kirk

David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
View more articles by David Kirk

The Conversation

Follow the reactions below and share your own thoughts.