How do I print a listing of files in a directory?

Updated: 12/30/2019 by Computer Hope
Canon printer

There are different methods of printing a listing of files. However, the method we're using in this document directs or sends the output to a file, which can be printed, instead of outputing directly to a printer. Microsoft Windows has no easy method of printing the output of a directory to a file or printer. Outputing to a file and printing that file is the next best solution.

Note

If you want to display the directory and not send it to a printer see our how to list files in a directory page.

Windows command line and MS-DOS

  1. Get to the MS-DOS prompt or the Windows command line.
  2. Navigate to the directory containing the content you'd like a list to print. If you're new to the command line, familiarize yourself with the cd command and the dir command.
  3. Once in the directory you want to print the contents of, type one of the following commands.
dir > print.txt

The command above takes all output of the dir command and writes it to the print.txt file in the current directory.

dir /b > print.txt

The command above prints only the names of files to the print.txt file and not the information of the files in the current directory.

dir /s /b > print.txt

The command above prints only the name of all files in the current directory and any subdirectories to the print.txt file.

  1. After executing any of the commands above, the print.txt file is created. Open this file in any text editor (e.g., Notepad) and print the file. You can also open Notepad from the command prompt by typing notepad print.txt.
Tip

If you have another default text editor, you can also use the start command to open the file with your default text editor. For example, type start print.txt to open the file in the default text editor.

Linux

  1. Navigate to the directory you want to print. If you're new to Linux, you need to familiarize yourself with the Linux cd command and the ls command.
  2. Once in the directory you want to print the contents of, type the following command.
ls > print.txt

The command above prints the name of all files in the current directory and any subdirectories to the print.txt file.