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

Updated: 06/02/2020 by Computer Hope
Canon printer

There are different methods of printing a listing of files. On this page, we cover how to send output to a file, which can be printed, instead of outputting directly to a printer.

Note

To only display a directory, see: How to list files in a directory or folder on the computer.

Windows command line and MS-DOS

Microsoft Windows has no easy method of printing the output of a directory to a file or printer. Outputting to a file and printing that file is the next best solution.

  1. Open 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.