Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

List File Names From a Folder in Excel

· 5 min read · Home Tech

In this article
  1. 1. Copy and Paste from File Explorer
  2. 2. Use the FILES Function (Excel 365)
  3. 3. Power Query (Get & Transform)
  4. 4. The Legacy Web Query Trick
  5. 5. VBA Macro with FileSystemObject
  6. 6. Use the "List" Option in Print Dialog
  7. 7. Command Prompt Redirect
  8. 8. Use a Third-Party Add-In Like ASAP Utilities
  9. 9. Google Sheets Workaround
  10. 10. Use a Named Range with the INDEX Function
  11. How to Choose
  12. Frequently Asked Questions
  13. Final Thoughts

This article covers the best ways to pull a list of file names from a folder into Excel, from quick copy-paste tricks to dynamic formulas and VBA. It's for anyone who regularly needs an inventory of files—whether you're a project manager, data analyst, or just someone tired of typing filenames by hand.

1. Copy and Paste from File Explorer

The fastest method when you need a one-time list: open the folder in File Explorer, press Ctrl+A to select all files, then hold Shift, right-click a selected file, and choose "Copy as path." Paste into Excel and use Find & Replace (Ctrl+H) to strip the full path, leaving just the file names. It takes under a minute and requires no formulas or coding.

2. Use the FILES Function (Excel 365)

Excel 365's new FILES function returns an array of file names from a folder path. Enter =FILES("C:\Users\Name\Documents\Folder\*") and press Enter—Excel spills the names down the column. It's dynamic: add a file to the folder and the list updates automatically. This is the cleanest modern solution if you're on a subscription version.

3. Power Query (Get & Transform)

Go to Data > Get Data > From File > From Folder, select your folder, and Power Query loads a table with file names, extensions, dates, and sizes. You can filter, sort, and even extract just the base name using the "Name" column. It's fully refreshable—right-click the query and hit Refresh to pull in new files. This is the best choice for recurring reports.

4. The Legacy Web Query Trick

An old but reliable trick: type =WEBSERVICE("file:///C:/Users/Name/Documents/Folder") in a cell to pull the folder's HTML listing from the file system. Excel returns raw HTML, which you can parse with FILTERXML to extract <a> tags. It's clunky and breaks on network paths, but it works without any add-ins or VBA on most desktop versions.

5. VBA Macro with FileSystemObject

For full control, a short VBA macro using FileSystemObject loops through files and writes names into a column. Press Alt+F11, insert a module, paste a few lines of code, and run it. You can capture subfolders, extensions, or file sizes in one pass. This is ideal for one-off heavy extractions or when you need to automate the process repeatedly.

6. Use the "List" Option in Print Dialog

In older Excel versions, you could print a folder's contents by going to File > Print and choosing "List" as the printer. This isn't available in modern Excel, but the same idea lives on in third-party tools. It's worth knowing about because many online tutorials still reference it—but skip it if you're on Office 2019 or later.

7. Command Prompt Redirect

Open Command Prompt in the folder (Shift+Right-Click > Open command window here), type dir /b > filelist.txt, and press Enter. This creates a text file with just the file names, one per line. Then import that text file into Excel via Data > From Text/CSV. It's fast, works on any Windows version, and needs no Excel skills.

8. Use a Third-Party Add-In Like ASAP Utilities

ASAP Utilities is a free add-in that adds a "List files in a folder" tool under its File menu. It lets you choose the folder, include subfolders, and output names, paths, sizes, and dates directly into a sheet. It's a one-click solution if you'd rather not write code or remember formulas. The free version is sufficient for most needs.

9. Google Sheets Workaround

If you're using Google Sheets, you can't directly list local files, but you can use =IMPORTXML("file:///C:/path", "//a/@href") on a local HTML file you generate. Or use the Google Drive API to list files from a Drive folder. This is more of a workaround, but it's handy if your team collaborates in Sheets and you need a shared file inventory.

10. Use a Named Range with the INDEX Function

For a non-VBA dynamic list, define a named range that references a helper column containing =FILES("C:\path\*") (if you have Excel 365). Then use =INDEX(Files, ROW()-1) to pull each name into a cell. This gives you a spill-free, drag-down list that updates when you add files. It's more complex but useful when you want to embed the list in a dashboard.

How to Choose

The right method depends on three things: how often you need the list, whether you need subfolders, and your comfort with tools. For a one-time list, copy-paste or Command Prompt is fastest. For recurring reports, Power Query is the winner because it refreshes with a click. If you need to automate within a workbook, VBA gives you the most control. If you're on Excel 365, the FILES function is the simplest dynamic option. Avoid the Web Query trick unless you're on an old version—it's fragile and hard to debug.

Frequently Asked Questions

Can I list only certain file types (e.g., .xlsx)?

Yes. In Command Prompt, use dir /b *.xlsx. In Power Query, filter the Extension column. In the FILES function, change the wildcard to *.xlsx.

How do I include subfolder file names?

Power Query includes subfolders by default. In VBA, set the Subfolders property to True. In Command Prompt, use dir /b /s to include subfolders.

Why does my FILES function return a #VALUE error?

It usually means the path is wrong or the folder doesn't exist. Double-check the path and use double backslashes in the formula. Also, ensure you're on Excel 365—older versions don't have this function.

Can I get file names without the extension?

Yes. After listing, use =LEFT(A1, FIND(".", A1)-1) to strip the extension. In Power Query, you can split the Name column by the dot delimiter.

Is there a way to list files in Google Sheets from my computer?

Not directly, because Sheets runs in the browser. You can upload the file list as a CSV or use a Google Apps Script to read from Drive. For local files, use Excel.

Does the list update automatically if I add new files?

Only with dynamic methods like the FILES function or Power Query (after refresh). Copy-paste and Command Prompt are static—you'd need to redo them.

Final Thoughts

Getting file names into Excel doesn't have to be tedious. Start with the copy-paste trick for quick jobs, then graduate to Power Query or the FILES function for anything you'll use more than once. Each method has its place, and knowing a few means you'll never be stuck typing filenames again.