Collect file names in folder Windows 7

Problem

If you need to collect all names of files in a given folder and then to write this list of names in text file you can use command dir.

Solution 1 Collect all names

  • Open Command Line in Windows 7 by
  • On keyboard press: WINDOWS + R
  • type cmd
  • Press Enter
  • Or in Start Menu write cmd and open cmd.exe
  • Go the your folder with

cd C:/folderWithTextFiles

  • Type

dir >fileNames.txt /b /o

In the folder: C:/folderWithTextFiles you will have file named fileNames.txt which will have all file names on separate lines.

Note - In order to exclude your output file you can change the output type to .log :

dir >fileNames.log /b /o

or simply delete the name fileNames.txt from the file at the end.

Solution 2 Collect all text file names

  • Open Command Line
  • Go the your folder with

cd C:/folderWithTextFiles

  • Type

dir *.txt >fileNames.txt /b /o

Solution 3 Collect all file names from a folder

  • Open Command Line
  • Type

dir "C:\Users\folder" >fileNames.txt /b /o

Related Article