Excel can list every file in a folder in two main ways: the quick manual route using the Windows address bar and File Explorer, or the automated route that pulls a folder's contents directly into Power Query and refreshes them on demand. The manual route works on any Windows PC with no setup at all and gives you a static snapshot; the Power Query route is better when the folder changes often and you want the list to update itself. Neither method deletes or moves anything, so both are safe to try.

What You'll Need

  • A Windows PC. The manual File Explorer trick depends on Windows behaviour; it does not work in Finder on macOS.
  • Excel installed, ideally a Microsoft 365 or Excel 2016-or-later desktop version. Excel for the web does not support the Power Query route described below.
  • The folder path (for example C:\Users\YourName\Documents\Reports) or the ability to navigate to it.
  • For the Power Query method, a folder that contains only files you want listed, since the query reads everything in it.
  • Permission to read the folder. If the folder is on a network share or a work drive, you need access rights to it.

Step-by-Step

Method one is the fastest way to get a one-off list.

  1. Open File Explorer and navigate to the folder whose files you want to list. If you only want certain file types, use the search box in the folder's toolbar and type something like *.pdf to filter results.
  2. Click the address bar at the top of the File Explorer window so the full folder path is highlighted. If you searched, press Ctrl+A inside the address bar first to select the path text.
  3. Type cmd and press Enter. This opens a Command Prompt window already pointed at that folder. If you filtered by search, press Ctrl+A again so the typed cmd replaces the path rather than appending to it.
  4. In the Command Prompt, type dir /b and press Enter. The /b switch produces a bare list of names with no dates, sizes or headers, which is exactly what pastes cleanly into a spreadsheet.
  5. Right-click anywhere inside the Command Prompt window, choose Select All, right-click again to copy, then paste into a blank Excel column. Names that were highlighted in File Explorer's quick-edit mode copy the same way, which is a shortcut when the folder has only a handful of files.
  6. In Excel, split names from extensions if you need to. Put =LEFT(A2,FIND("~",SUBSTITUTE(A2,".","~",LEN(A2)-LEN(SUBSTITUTE(A2,".",""))))) in a helper column to cut everything before the final dot and =RIGHT(A2,LEN(A2)-FIND("~",SUBSTITUTE(A2,".","~",LEN(A2)-LEN(SUBSTITUTE(A2,".",""))))-1) to pull the extension, then drag down.

Method two builds a live list with Power Query. Menu labels can differ slightly by Excel version, device or region.

  1. Save the Excel workbook outside the folder you are listing. If the workbook sits inside that folder, its own name will appear in the results and the list will change every time you save.
  2. On the Data tab, choose Get Data > From File > From Folder. A dialog opens asking for a folder path.
  3. Browse to the folder or paste the path into the box, then click Open. Excel scans the contents and shows a preview window.
  4. In the preview, click Transform Data instead of Load. This opens the Power Query Editor, where you can shape the table before it lands on a sheet.
  5. In the query, keep the Name column for file names, and if you want more detail, click the icon in the Content column header and choose to expand available attributes. The exact attribute names (date created, date modified, folder path, extension) vary by source and version, so pick only the ones you recognise.
  6. Right-click any columns you do not want, such as the binary Content column, and choose Remove Columns. Rename the remaining headers by double-clicking them.
  7. Click Close & Load. Excel writes the result to a new table on a fresh sheet.
  8. Later, after files are added or deleted, click anywhere in the table and press Alt+F5, or use Data > Refresh All, to update the list.

Common Mistakes

  • Typing cmd into the search box, not the address bar. That runs a web search or a Windows search instead of opening a prompt at the folder.
  • Leaving search active. If the address bar already contains a search query, typing cmd appends to it. Always clear or reselect the text first.
  • Not using /b. Plain dir output includes date, time, size and summary lines that clutter the spreadsheet.
  • Storing the workbook inside the listed folder. The workbook lists itself, and each save changes the modified date, so the table never looks stable.
  • Assuming it works on a Mac. Finder has no equivalent command-line trick in the same way. Command-line tooling differs substantially, and Excel for Mac's Power Query folder connector follows a different flow.
  • Expecting the manual list to update. The pasted list is frozen text. Files added later will not appear.

Tips

  • Use dir /b /s to include subfolders and their full paths, or dir /b /o:n to sort alphabetically.
  • Filter by file type before running the command. Searching *.xlsx in File Explorer and then running cmd from the address bar does not carry the filter across, so use dir /b *.xlsx instead.
  • Turn the pasted names into a Table with Ctrl+T so filters, sorting and formulas apply across the whole list automatically.
  • For a reusable Power Query route, keep the workbook and folder in fixed locations. Moving either one means editing the source path.
  • Number the rows after pasting and sort by extension to group documents by type quickly.

Troubleshooting

The Command Prompt opens in the wrong folder. Close it and repeat the address-bar step slowly, confirming the path is highlighted before you type. Alternatively, open Command Prompt and type cd /d followed by the folder path in quotes.

Nothing pastes properly. Select the text again with Select All and copy from the menu rather than dragging. Long lists paste best as plain text; use Paste Special > Text if Excel tries to interpret anything.

Power Query shows an error about the path. Check for typos, a missing drive letter or a disconnected network drive. Reconnect the share and refresh. If the folder requires credentials, Excel will prompt for them once per session.

The refreshed table shows old data. Confirm you refreshed the right query, and check that the source path still points at the intended folder. If the workbook moved, update the path in the query's source step.

Excel is slow or crashes with a very large folder. Limit the columns you load, remove the Content column early, and avoid listing folders with thousands of files if you only need names. The manual method handles big folders more predictably for a one-time export.

If that did not work: try the alternative method. When the automated route fails, the manual command-line route almost always still works, and vice versa.

Frequently Asked Questions

Does this work on Excel for Mac?

The address-bar cmd trick is Windows-only. On a Mac, use a Terminal command such as ls in the folder, or use the Power Query folder connector, whose screens differ from the Windows version.

Will the list update when I add a new file?

Only with the Power Query method, and only after you refresh. A list pasted from the Command Prompt is static text.

Can I include file sizes and dates?

Yes. Use dir without /b to get dates, times and sizes, or expand the attribute columns in Power Query.

Can I list files from a network drive?

Yes, as long as you have read access. Use the mapped drive letter or the full network path in the address bar or Power Query dialog.

Does listing files copy or move anything?

No. Both methods only read names and properties. Nothing in the folder is changed.

Is there a formula that does this?

Not a built-in worksheet function. Excel has no live function that reads folder contents, so use Power Query, the command line, or a macro.