How to Print Directory Contents Using Different Methods

You can copy folder contents by selecting all items in a folder, pressing Shift key and clicking the Copy as Path command in the right-click menu. Then open Notepad or any other text editor and paste the contents from the clipboard.

print directory contents in windows - copy as path

But if you need to print the directory list for the current folder and subfolders recursively, you need a different approach. This article discusses different ways to list folder contents including the Windows command-line method, using Google Chrome, Firefox web browser, or SysExporter.

Different Methods to Print Directory Listing

Print Directory Contents using Command Prompt

  1. Open the folder for which you want to print the directory listing.
  2. Type cmd.exe in the address bar to open Command Prompt in the current folder.
  3. Type the following command and press ENTER:
    dir /o:gn

    This shows the list of files and folders in that directory.

    Copy to clipboard

    To output the directory contents list to the clipboard, use the following command:

    dir /o:gn | clip

    Then, to view the output, open Notepad and paste the contents from the clipboard.
    print directory contents in windows

    Print the output to file

    Alternately, you can also write the output directly to the %temp%\printdir.txt temporary file, using the following command-line:

    dir /o:gn > "%temp%\printdir.txt"

    Then, open the %temp%\printdir.txt file using Notepad.

    To list the directory contents recursively (including subfolders), use the /s argument:

    dir /o:gn /s > "%temp%\printdir.txt"

Add Print Directory to the right-click menu

To add the Print Directory List command to the right-click menu, follow these steps:

  1. Open Notepad, and copy the following text to Notepad:
    Windows Registry Editor Version 5.00
    @="Print Directory Contents"
  2. Save the file as print_dir.reg and double-click print_dir.reg to run it.

This adds a Print Directory Contents command to the right-click menu for folders, which when clicked, shows the directory contents using Notepad automatically.

print directory contents in windows

Note: The hex code above translates to the following command:

cmd.exe /c dir /-p /o:gn "%1">%temp%\printdir.txt && start notepad.exe %temp%\printdir.txt

The command is created in the following registry key:


print directory contents in windows

Sample output when you click Print Directory Contents:

Volume in drive D has no label.
Volume Serial Number is F4AC-F4D1

Directory of D:\Websites\uploads\2019\02

05/20/2019 12:18 AM <DIR> .
05/20/2019 12:18 AM <DIR> ..
05/20/2019 12:18 AM 13,751 800f081f-0x20003.png
02/24/2019 10:47 AM 39,751 set-pin-error-0x80090016.png
02/23/2019 07:46 PM 106,081
05/20/2019 12:18 AM 11,812 w10-disable-developer-mode.png
02/23/2019 07:46 PM 10,505 w10-userprofile-failed-sign-in.png
5 File(s) 181,900 bytes
2 Dir(s) 274,388,795,392 bytes free

Print directory listing in Tree format

To print the directory contents in a tree format, use this command-line syntax:

TREE [drive:][path] [/F] [/A]

/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.

The TREE command always lists the items in the current folder and subfolders recursively. But the tree output wouldn’t have any details other than the file and folder names.


tree /f /a d:\backup\tweaks | clip

Sample output of the Tree command:

print directory contents in windows

Add “Print Directory Contents (Tree)” to the right-click menu

To add Print Directory Contents (Tree) in the right-click menu for folders:

  1. Using Notepad, make a .reg file from the following contents:
    Windows Registry Editor Version 5.00
    @="Print Directory Contents (Tree)"
  2. Run the .reg file by double-clicking on it.

The hex code above translates to the following command-line:

cmd.exe /c tree /a /f "%1" >%temp%\printdir.txt && start notepad.exe %temp%\printdir.txt

This adds the Print Directory Contents (Tree) command to the right-click menu for folders.

print directory contents in windows - tree command

Print Directory Contents using Google Chrome

Open Google Chrome, type the folder path in the address bar, and press Enter. This shows the folder contents, sorted by Name with folders on top. You can sort it as you’d like – by Size or Date Modified column – thanks to Chrome’s sortTable JavaScript function.

print directory contents chrome firefox

While the file and folder icons are shown in the normal view, they won’t be outputted when you print directory contents to a physical printer or output to a file.

print directory contents chrome firefox

Print Directory Contents using Mozilla Firefox

In Mozilla Firefox, directory listings are shown in a better way, with a better style sheet.

Click the Name column header to sort the listing by name with folders on top.

print directory contents chrome firefox

The file and folders icons look neat, but you most likely don’t want to see them in print. Unlike Google Chrome, Firefox’s print preview dialog would show/print the icon for every file and folder.

You can apply your own styling to the directory contents page, and remove the file/folder icons from being printed.

Add or Remove Custom Styles

Launch the Firefox Developer Tools / Inspector by pressing Shift + F7. Alternately, use F12 (or Ctrl + Shift + i) and click “Style Editor”.

print directory contents chrome firefox

Add the following to the Style Sheet Editor.

.dir::after { content: "/" }
img { display:none }

Then remove the following lines from “Inline Style Sheet #1” in the Style Editor window.

.dir::before {
content: url(resource://content-accessible/html/folder.png);

.dir ,
.symlink ,
.file {
margin-inline-start: 20px;

Also, remove the following styles from the DirListing.css

.dir::before {
content: url(chrome://global/skin/dirListing/folder.png);

Doing so would hide the file and folder icons to prevent them from being printed. Also, to easily differentiate between files and folders, the custom stylesheet code adds a trailing forward-slash (“/“) after the directory name. Chrome, on the other hand, does this by default.

Close Developer Tools (Ctrl + Shift + i).

So here is what the print preview looks like, and so would the final output to the printer or a PDF file.

print directory contents chrome firefox

print directory contents chrome firefox

Note: In Internet Explorer or Microsoft Edge, when you type a directory path the folder window is launched rather than the browser rendering the folder contents.

Print Directory Contents using SysExporter

Nirsoft’s SysExporter allows you to grab the data stored in standard list-views, tree-views, list boxes, and combo boxes from almost any application running on your system, and export it to text, HTML or XML file.

RELATED: We’ve also covered SysExporter in the article How to Print Your Windows Update History By Exporting to Text or HTML File
  1. Open the folder for which you want to export the directory list. For example, here’s my Downloads directory:
    get directory listing - sysexporter
  2. Switch the folder view to “Details“. This is an important step.
  3. Enable the required columns and sort items accordingly.
  4. Download SysExporter.
  5. Run SysExporter. If the window you want to capture is running elevated, then start SysExporter as administrator.
  6. In SysExporter, click on the crosshair icon on the toolbar and drop it on the folder window whose contents you want to capture.
    get directory listing - sysexporter
    (This shows you the list of items in that folder, exactly as you see in the folder view.)
    get directory listing - sysexporter
  7. In the lower pane, select all the entries (Ctrl + A)
  8. Press Ctrl + C. Or, from the “Items” menu, select Copy Selected Items (Tab Delimited)
  9. Open Notepad and paste the text from the clipboard.
  10. Save the Notepad document.

You can also open the exported tab-delimited file using Microsoft Excel and apply the required fonts and formatting with column headers.

Alternatively, you can export the listing to a HTML file. To do so, click “HTML Report (All items)” from the “Items” menu.

get directory listing - sysexporter

SysExporter can be very useful especially when you want to capture the metadata columns (e.g., for a Music or Videos folder) in a folder view and export the listing to a file.

One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded in 2005.

2 thoughts on “How to Print Directory Contents Using Different Methods”

  1. I am very interested to learn Ramesh if your previous findings still stand in Chrome Windows 10 in printing off file directories. Yours to date seem to make the only sense but just wondering if there has been any advancement. Thank you for the hard work you do

    • @Petra: The info still holds good for Chrome Version 97.0.4692.99 – January 2022. The Firefox part in this post has been updated for the current version (96.0.3, as of the revision).

Leave a Comment