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

Canon printerThere are different methods of printing a listing of files; however, the method we will be using in this document is directing or sending the output to a file so that file can be printed, instead of directly to a printer. Because Microsoft Windows has no easy method of printing the output of a directory to a file or printer.

Windows command line and MS-DOS users
Linux users

Windows command line and MS-DOS users

  1. Get to the MS-DOS prompt or the Windows command line.
  2. Navigate to the directory you want to print the contents of. 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 below commands.

    dir > print.txt

    The above command takes the list of all the files and all of the information about the files, including size, modified date, etc., and send that output to the print.txt file in the current directory.

    dir /b > print.txt

    This command would print only the file names and not the file information of the files in the current directory.

    dir /s /b > print.txt

    This command would print only the file names of the files in the current directory and any other files in the directories in the current directory.

  4. After doing any of the above steps the print.txt file is created. Open this file in any text editor (e.g. Notepad) and print the file. You can also do this from the command prompt by typing notepad print.txt.

Linux users

  1. Navigate to the directory you want to print the contents of. If you're new to Linux, you will 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 one of the below commands.

    ls > print.txt

    Print each of the files and directories in the current directory to the print.txt file.

Additional information