How to get a list of files in a Windows folder

Contents

When I was asked a question about how to quickly send a list of files to a text file, I realized that I did not know the solution. Even though the task seemed common enough. You may need it to send a list of files to a specialist (to solve an obstacle), to record the contents of folders yourself and for other purposes.

It was decided to fill the gap and prepare a tutorial on the subject, showing how to get a list of files (and subfolders) in a Windows folder using the command line, and how to automate this procedure if the task occurs many times.

Retrieve a text file with the contents of a folder on the command line

First, about creating a text document containing a list of files in the desired folder manually.

  1. Run the command line as administrator.
  2. Come in . CD X:File… where x: folder is the full path of the folder whose file list you want to recover. Enter pulse.
  3. Enter the command to you /to /-pag /O:gen>records.TXT (where files.txt is the text file in which the list of files will be saved). Enter pulse.
  4. If you use the command with / b (to you /to /B / –pag /O:gen>records.TXT), the resulting list will lack additional information about the size of the files or the creation date: just a list of names.

Done. The result will be a text file with the required information. In the above command, this document is saved in the same folder from where you want to retrieve the file list. Furthermore it is feasible to omit the output to a text file, in which case the list will only appear on the command line.

At the same time, for Russian-speaking Windows users, note that the file is saved in windows encoding 866, which means you will see the hieroglyphs instead of the Russian characters in a normal notepad (but you can use an alternative text editor to display, as an example Sublime text).

Get a list of files with Windows PowerShell

Additionally you can get a list of files in a folder through Windows PowerShell commands. If you want to save the list to a file, run PowerShell as administrator, if you just want to see it in a window, a simple throw is enough.

Command example:

  • Get-Childitem -Path C: Folder: outputs a list of all files and folders located in the Folder folder on drive C in the Powershell window.
  • Get-Childitem -Path C: File | Out-File C: Files.txt: create a files.txt text file with a list of files in the folder.
  • If the -Recurse parameter is added to the first command described, also the content of all the subfolders of the list is obtained.
  • The -File and -Directory parameters allow you to list only files or only folders, respectively.

Not all Get-Childitem parameters are listed above, but within the scope of the task described in this tutorial, I think they will be enough.

Microsoft Fix it utility to print the contents of a folder

There is a Microsoft Fix It utility at https://support.microsoft.com/ru-ru/kb/321379 adding an item “Print Directory List” to the browser context menu, which prints a list of files in a folder.

Even though the program is only for Windows XP, Vista and Windows 7, also worked successfully on Windows 10, all i had to do was run it in compatibility mode.

At the same time, the same page shows how to manually add file list output command to explorer, with Windows variant 7 also suitable for Windows 8.1 Y 10. And if you don't need to print the output, you can slightly modify the commands. suggested by Microsoft by removing the parameter / p in the third line and removing the fourth line entirely.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.