Search code examples
windowsbatch-filefile-listing

Batch writing file names to a text file


I have a folder "C:/files" it will have say 10 files in it how would I write the files name to a text file called files.txt. I need it so the names are all in septate lines so it will look something like this.

file1
file2
file3
ect

Thanks if any one can help.


Solution

  • Under the folder (cd into it, or simple in the folder, SHIFT+Right click and select Open command window here), you can run the following dos command:

    Dir /b *.* > list.txt
    

    P.S. if you need the full path of each file, you can add extra /s option:

    Dir /s /b *.* > list.txt