Home/Guides/List file names in Excel

How to get a list of file names into Excel

Last updated . Takes about 2 minutes.

Most rename jobs start the same way: you need the current filenames in a spreadsheet so you can type, look up or generate the new ones next to them. Windows and macOS can both produce that list without any extra software. This guide shows the reliable ways to do it, then how to turn the list into a finished rename.

MethodSystemBest for
dir /b in Command PromptWindowsFastest, plain English filenames
PowerShell Export-CsvWindowsA ready-made rename sheet; accented or non-Latin names
Explorer "Copy as path"WindowsPicking only some files by hand
Power Query "From Folder"Excel for WindowsA list you can refresh later, with dates and sizes
ls in TerminalMacWhole folder in one line
Finder "Copy as Pathname"MacPicking only some files by hand

Windows: Command Prompt (dir /b)

Open the folder in File Explorer, click the address bar, type cmd and press Enter. A Command Prompt opens already inside that folder. Then run:

dir /b /a-d /on | clip

/b prints bare names (no dates or sizes), /a-d leaves out subfolders, /on sorts by name, and | clip puts the result on the clipboard. Click cell A2 in Excel and paste. To save a file instead, write it somewhere outside the folder so the list does not include itself:

dir /b /a-d /on > "%USERPROFILE%\Desktop\filelist.txt"

Watch for garbled characters. Command Prompt output uses an old code page, so names with accents, Chinese or Cyrillic characters can come out wrong. If you see that, use PowerShell instead.

Windows: PowerShell, straight to a rename sheet

In Windows 11, right-click an empty area of the folder and choose Open in Terminal. In Windows 10, use File → Open Windows PowerShell. This one command writes a CSV with an Old name column already filled and an empty New name column waiting for you:

Get-ChildItem -File | Sort-Object Name |
  Select-Object @{Name='Old name';Expression={$_.Name}}, @{Name='New name';Expression={''}} |
  Export-Csv -Path "$HOME\Desktop\filelist.csv" -NoTypeInformation -Encoding UTF8

In Windows PowerShell 5.1 (the one built into Windows), -Encoding UTF8 writes a byte-order mark, which is what Excel needs to show non-English names correctly. In PowerShell 7 the same switch writes no byte-order mark, so use -Encoding utf8BOM there. If you only want the names on the clipboard:

Get-ChildItem -File -Name | Set-Clipboard

Windows: Explorer "Copy as path"

Select the files (Ctrl+A for all), then press Ctrl+Shift+C in Windows 11, or hold Shift, right-click and choose Copy as path in Windows 10. Paste into column A. Each cell looks like "C:\Shoots\IMG_0412.JPG", so clean it up with Find and Replace (Ctrl+H) on that column:

  1. Find *\, replace with nothing, Replace All. This removes the folder part and the opening quote.
  2. Find ", replace with nothing, Replace All. This removes the closing quote.

Excel for Windows: Power Query "From Folder"

In Excel go to Data → Get Data → From File → From Folder, choose the folder and click Transform Data. You get a table with Name, Extension, Date modified, Folder Path and more. Two things to know:

Mac: Terminal (ls)

Open Terminal, type cd (with a trailing space), drag the folder from Finder into the window and press Enter. Then:

ls -1p | grep -v / | pbcopy

-1 prints one name per line, -p adds a slash to folder names so grep -v / can drop them, and pbcopy copies the result. Hidden files are skipped. Paste into column A. To save a file instead: ls -1p | grep -v / > ~/Desktop/filelist.txt

Mac: Finder "Copy as Pathname"

Select the files, then press Option-Command-C (or hold Option and open the Edit menu: Copy … as Pathname). Paste into column A, then in Excel's Find and Replace, find */ and replace with nothing to keep only the filenames.

Add the new-name column

Put Old name in A1 and New name in B1. Mass Rename recognises those headers, along with variants such as original/target or from/to. Then fill column B however suits the job, and double-click the fill handle to copy the formula down:

GoalFormula in B2
Add a prefix="2026-acme-"&A2
Number the files="report-"&TEXT(ROW()-1,"000")
Look up the name in another sheet=XLOOKUP(A2,Codes!A:A,Codes!B:B,"")

You do not need to manage extensions. Whether column B says report-001 or report-001.pdf, the file keeps the extension it has on disk. A row whose new name is blank is flagged in the preview and skipped, so a failed lookup never produces an empty filename.

Rename the files from the list

  1. Save the sheet as .xlsx or .csv, and open the renamer.
  2. Drop the sheet on the first box. If the workbook has several sheets, pick the one with your list. Check that the two columns were detected correctly; you can change them.
  3. Add the files: select them in Explorer or Finder, or drop a ZIP of them.
  4. Read the preview. Every file shows Will rename, Name already matches, Name conflict or Illegal name, and rows that match no file are listed separately.
  5. Click Download renamed ZIP. In Chrome or Edge you can choose Rename in a local folder instead, which renames the files in the folder you pick and offers Undo the last rename.

The spreadsheet and the files are read inside your browser tab; nothing is uploaded. For more detail on matching rules, see renaming files from an Excel list.

Frequently asked questions

How do I get a list of file names into Excel without VBA?

Use dir /b /a-d | clip in Command Prompt or Get-ChildItem -File -Name | Set-Clipboard in PowerShell on Windows, or ls -1p | grep -v / | pbcopy in Terminal on a Mac, then paste into Excel. Excel for Windows can also read a folder directly with Data → Get Data → From File → From Folder.

How do I include files in subfolders?

Use dir /b /s /a-d (full paths) or Get-ChildItem -File -Recurse; Power Query includes subfolders by default. Mass Rename matches on the filename, so two files with the same name in different subfolders are flagged as a conflict rather than guessed. Rename in a local folder works on the files directly inside the folder you pick, while a dropped ZIP keeps its folder structure in the output.

Why do accented or Chinese filenames look garbled?

Command Prompt writes text in a legacy code page. Use the PowerShell command with -Encoding UTF8 (Windows PowerShell 5.1) or -Encoding utf8BOM (PowerShell 7) so Excel reads the names correctly.

Can I list file sizes and dates as well?

Yes. In PowerShell: Get-ChildItem -File | Select-Object Name, Length, LastWriteTime | Export-Csv -Path "$HOME\Desktop\files.csv" -NoTypeInformation -Encoding UTF8. Power Query also includes Date modified and Date created columns.

Do I have to include the extension in the new name?

No. Mass Rename keeps the extension the file already has, whether or not your new-name column includes one.

Are my files uploaded when I rename them?

No. The sheet is parsed and the files are renamed inside your browser tab. Nothing is sent to a server.

Open the renamer →

Prefer it one click away? Mass Rename also runs as a browser extension: Add to Chrome · Add to Edge. The first 50 files in every batch are free; unlimited is $19 once.

Next: renaming from an Excel list · renaming from a CSV · batch rename on Mac and Windows · renaming from Google Sheets · renaming photos from a list · all guides