I have a few hundred files in a folder on a Windows 7 machine. Is there a way to generate an XLS, or CSV file from the file names in the folder?

A text file is fine as well; Just looking for any method to automatically extract the file names.

4 Answers 4


One very quick and dirty way is the command prompt. Simply open one, navigate to your folder and funnel the result into a text file using this command:

dir > filenames.txt

You will have to do some cleaning up, but as I said "quick and dirty". :-) If you only want certain objects you can of course limit the output of your 'dir' command.

The option Cybertox mentioned might be a good idea:

/B Uses bare format (no heading information or summary).

  • 11
    dir /b would get you just the filenames
    – Shazvi
    Apr 22, 2014 at 16:21
  • dir /b - all files ... except hidden files. If you want those, include /a. For more options try dir /? Apr 24, 2014 at 11:15

You can use PowerShell to create an actual CSV file:

dir | Export-Csv MyFileList.csv

  • It puts the result in the folder. I would then open it in VS Code using the Excel Viewer extension (this is a much lighter weight way to view Excel and CSV). May 8, 2019 at 17:54
  • 1
    Thanks, found this useful. Please all, be aware that this added MyFileList to the file list!
    – PJRobot
    Nov 3, 2020 at 18:01

This used to work on older Windows versions and gave the full path of all files:

dir /s /b > list.txt
  • 1
    Assuming you don't want the directory names of the directories each directory contains, use: dir /s /b /a-d > list.txt
    – Engineer
    Apr 23, 2014 at 1:09

If you also want the metadata (owner, size, modified date), see PowerShell command to write directory to CSV for a one-liner

Powershell code from source by Andrew Z.

powershell "Get-ChildItem -Filter *.mp3 -Recurse E:\media\music\ | ForEach-Object {$_ | add-member -name "Owner" -membertype noteproperty -value (get-acl $_.fullname).owner -passthru} | Sort-Object Length -Descending | Select FullName,Name,Length,CreationTime,LastWriteTime,Owner | Export-Csv -Force -NoTypeInformation c:\temp\mpeg-3.csv"

This is slightly changed to fufill the criteria drewdqueue needed, which was all MP3 files in descending order or size and Name as a seperate entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.