How to get a list of files in the Windows folder

Anonim

Getting a list of files from the folder in Windows
When I turned to me about how to quickly display a list of files into a text file, I realized that I did not know the answer. Although the task, as it turned out, is quite common. This may be required to transfer the file list by a specialist (to solve some problems), independent logging of folder content and other purposes.

It was decided to eliminate the gap and prepare the instructions on this topic in which it will be shown how to get a list of files (and subfolders) in the Windows command line folder, as well as how to automate this process if the task occurs often.

Getting a text file with a folder content on the command line

Getting a list of files on the command line

First, how to make a text document containing a list of files in the desired folder manually.

  1. Run the command prompt on behalf of the administrator.
  2. Enter CD X: \ Folder \ where X: \ Folder \ - the full path to the folder, the list of files from which you want to get. Press ENTER.
  3. Enter the DIR / A / -P / O: GEN> Files.txt command (where files.txt is a text file in which the file list will be saved). Press Enter.
  4. If you use the command with the / b (DIR / A / B / -P / O: GEN> Files.txt), then the list will be missing any additional information about the sizes of files or the creation date is only a list of names.

Ready. As a result, a text file containing the necessary information will be created. The command is higher, this document is saved in the same folder, the list of files from which you want to get. You can also remove the output to the text file, in this case the list will be displayed only on the command line.

The resulting text file with a list

In addition, for users of the Russian-language version of Windows, it should be considered that the file is stored in the Windows 866 encoding, that is, in the usual notepad instead of Russian characters, you will see hieroglyphs (but you can use an alternative text editor to view, for example, Sublime Text).

We receive a list of files using Windows PowerShell

You can also get a list of files in the folder using Windows PowerShell commands. If you want to save a list to a file, then run PowerShell on behalf of the administrator, if easy to view in the window - quite simple startup.

Saving a list of files to a text file in PowerSehll

Examples of teams:

  • Get-Childem -Path C: \ Folder - output of the list of all files and folders located in the folder folder on the C disk in the PowerShell window.
  • Get-Childem -Path C: \ Folder | Out-File C: \ Files.txt - Create a text file Files.txt with a list of files in the folder folder.
  • Adding the -Recurse parameter to the first command described displays the contents of all subfolders in the list.
  • -File and -Directory parameters allow you to get a list of only files or only folders, respectively.
List of files received in PowerShell

The above is not all the parameters of Get-ChildItem, but within the framework of the task described in this guide, I think there will be enough.

Microsoft Fix IT utility for printing the contents folder

On the https://support.microsoft.com/ru-ru/kb/321379 there is a Microsoft Fix IT utility, adding the "Print Directory Listing" to the context menu, the list of files in the print folder.

Output of the list of files to print through the context menu

Despite the fact that the program is intended only for Windows XP, Vista and Windows 7, it successfully worked in Windows 10, it was enough to run it in compatibility mode.

Additionally, on the same page, the order of manual adding a file output command to the conductor is shown, and the option for Windows 7 is also suitable for Windows 8.1 and 10. And if you do not need to print, you can fix the commands offered by Microsoft commands, deleting the parameter / P in the third line and completely removing the fourth.

Read more