How-To Geek

How to Print or Save a Directory Listing to a File


Printing a directory listing is something you may not do often, but when you need to print a listing of a directory with a lot of files in it, you would rather not manually type the filenames.

You may want to print a directory listing of your videos, music, ebooks, or other media. Or, someone at work may ask you for a list of test case files you have created for the software you’re developing, or a list of chapter files for the user guide, etc. If the list of files is small, writing it down or manually typing it out is not a problem. However, if you have a lot of files, automatically creating a directory listing would get the task done quickly and easily.

This article shows you how to write a directory listing to a file using the command line and how to use a free tool to print or save a directory listing in Windows Explorer.

Using the Command Line

Printing or saving a directory listing using the command line is an easy, straightforward process. First, there is an easy way to open a command window to a specific directory. In Windows Explorer, navigate to the directory for which you want to print or save the listing. Press the Shift key while right-clicking on the directory. Select Open command window here from the popup menu.


At the command prompt, type the following command and press Enter.

dir > print.txt


A file called print.txt is created in the directory.


When you open the file in Notepad, or in your favorite text editor or word processor, you will see the same directory listing you would see in the command window using the “dir” command alone.


If you want just a list of the filenames, you can run:

dir /b > print.txt

Using a Free Tool

There is an easy way to print and save directory listings using a free tool. Directory List & Print allows you to generate directory listings that can be customized, saved as files, and printed.

NOTE: There is a Freeware version and a Pro version of Directory List & Print. There are features in the program that are grayed out in the Freeware version unless you purchase the Pro version for $20. However, the Freeware version still provides plenty of flexibility for generating directory listings you can print or save.

Directory List & Print is a portable program that does not need to be installed. Simply extract the downloaded .zip file (see the link a the end of the article) and run the .exe file.

One especially handy feature of Directory List & Print is the ability to add an option to the Explorer directory context menu for directories. This allows you to quickly generate a listing for a directory from within Explorer. To do this, you must run the program as administrator. Right-click on the .exe file and select Run as administrator from the popup menu.


When the program opens, select Add to Directory Context Menu from the Setup menu.


An Information dialog box displays saying that the option has been added to the context menu.


To generate a listing of a directory, right-click on a directory in Windows Explorer and select Open in Directory List + Print from the popup menu.


The program opens and a listing of the selected directory displays in the text box at the bottom of the window that is always visible no matter which tab is active at the top of the window. The Directory tab displays allowing you to manually select a directory and to set up Favorites, or directories for which you might generate listings often. Some common system directories have already been added to Favorites for easy access.


The Selection tab allows you to specify what is displayed in the directory listing, such as the date, time, and size.


The Output tab allows you to send the listing directory to a printer or copy the listing to the clipboard for pasting into any text editor, word processor, or other program that accepts plain text. You can also open the listing directory in Word or Excel from within Directory List & Print.


For example, here’s a directory listing of .mp3 files in Excel. The columns are automatically placed into columns in the spreadsheet.


We also copied the listing to the clipboard and pasted it into Notepad. The columns are appropriately spaced like a table.


Because Directory List & Print is not installed, there is no shortcut for the program on the desktop. You can add one using the standard Windows method, or you can easily add a shortcut to the desktop from within the program. Simply select Add Program Shortcut to the Desktop from the Setup menu.


If you want a listing of a directory on a network drive, use the Network Drive options on the Setup menu in Directory List & Print. You can also drag and drop a directory from Windows Explorer onto the program window to quickly generate a listing of that directory.

Download Directory List & Print from

Lori Kaufman is a writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 11/17/11

Comments (24)

  1. Jun

    I use TREE command instead.

  2. JP

    The command line in super easy.

    This will put a list of all your pictures in a directory into a text file called list.txt in order by name:

    dir *.jpg /o:n > list.txt

  3. Chuck Anderson

    Taking the command line option one step farther, you can add the option /S to create a listing that includes all sub directories “dir /S print.txt” Also if you already have a text file, and you want to append your directory listing to it use “dir >> print.txt” or dir /S >> print.txt”

    Fora complete listing of options of the dir command type “dir /?” the /? option works for most dos commands as well.

  4. benw

    Another good and free program is Karen’s Directory Printer:

  5. blzeebub

    Personally I use the “| clip” pipe function of the Windows 7 command shell … this sends whatever you’ve listed in the directory to the clipboard, from where you can do whatever you want with it – for instance , for JP’s example “dir *.jpg /o:n | clip” , and for Chucks “dir /s | clip”

  6. Exshail

    With Workbook navigation Excel Addins onne can have a list with hyperlink of directory listing in Excel Worksheet. You can download this addins from

  7. Keith

    Two more options. One is Print Folder 1.3.

    The other is ok if you just want a listing of whatever files and folders are in the current one.
    In Win7, go to whatever folder, select all the entries (ctrl A), shift-right-click and choose ‘copy as path’. Paste that into your text editor or word processor of choice.

  8. Dave

    You can also when doing the dir if you dir /b it will strip all the info out apart form the file names

  9. samir

    anather way is using windows powershell command

    Get-ChildItem [path] -recurse

    you will get detailed list of files in folder as well as sub-folders

  10. Chris Haworth

    Just run this macro in Excel…..Providing your filelist is in txt file D:\filelist.txt

    Sub FileList()
    Workbooks.OpenText Filename:=”D:\filelist.txt”, Origin:=xlMSDOS, StartRow _
    :=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), Array _
    (18, 1), Array(26, 1), Array(36, 1)), TrailingMinusNumbers:=True
    End Sub

    Then you can play around with it as much as you like.

  11. Dano

    Just drag and drop the folder into your FireFox icon. Ctrl+P the resulting window. Done.

  12. Darlene Kell

    Even more simple, if you have ANY version of WordPerfect on your computer, once you have the directory list up on screen, under “File,” select “Print File List” and you can either send it directly to the printer, save it in Word Pad or put it on the Clipboard – no macros to run- no command lines – no extra software. I’ve always kept a version of WordPerfect on my computer as it still has some great functions that WORD doesn’t or ever will have.

  13. Betty

    This is great. I opened the txt file in Word, then replaced two spaces with a tab until there were no two-space combinations left. Then I replaced two tabs with one tab until there were no two-tab combinations left. Then I converted it all to a table. Voila! And it took me less time than adding this comment!!

    Another great tip from HTG!

  14. Leonick

    Indeed you can, but I don’t know why you would use Get-ChildItem when dir or ls work just as fine as they are preset aliases for Get-ChildItem, why type a so much longer command when you don’t have to?

  15. Sharon

    I am assuming this is for Vista or Windows 7? Right clicking on directories in XP does not give me any of these commands.

  16. Nebi

    tree /a /f >tree.txt
    attrib * /s /d >attrib.txt
    dir /s /d >dir.txt

    The command line is so useful.

  17. Todd

    Cmd line is Way Cool. Been needing to do this.

  18. Terry

    For XP, open a command prompt and navigate to the desired directory.
    Or you can install XP “Open Command Window Here” Power Toy (Microsoft)

    This will allow you to right click any folder and open a command prompt window there.

  19. Henry

    Why not use Karens Directory Printer. Far more options and it is very easy to use once you have set it up for the format you want.

  20. Davel

    Another alternative – ExpPrint:
    It caters for listing all the basic file system properties and loads of metadata properties for media files too.

  21. Hariks

    BTW, I use ‘Type’ command to merge more than one text files…

    “type *.txt > all.txt

  22. miko

    Directory Lister 0.9.1

  23. Az

    Hi all,
    this method with command line is great, I think we could also use the following to skip the creation of text file:
    dir | clip
    Of course, this one requires Windows 7 or Vista or manually downloaded ‘clip’ file.
    Anyway, I found another method that I’ve been using and I think it’s much more suitable for ‘normal’ user, that means, for example you need a file list of the current folder.
    This method uses Autohotkey, the script is:
    ControlGetText, CurrentAddress, Edit1,A
    Run, cmd /c dir “%CurrentAddress%” /a:-d-h-s /b /o:gn | clip,, hide
    Note: I use Ctrl+Shift+C to copy, you can change it to whatever you want.
    Under Windows Vista or 7, the address bar of explorer is changed to ‘clickable’ buttons, and that makes getting the path of current folder impossible for me, so I’d say, you first highlight the path in the address field, than press the combination.
    The file list will go to clipboard.

  24. Sattamander

    What OS are you using since there is no such entry as “Open command window here” in XP?

    Loved the Firefox solution! Kudos to Dano

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!