A folder holds hundreds of files, and you need their names in a spreadsheet without typing each one. In Windows 11, the quickest route is to select the files in File Explorer, right-click and choose Copy as path, paste into Excel, and strip the folder part. For a list that updates itself, use Excel’s Data > Get Data > From File > From Folder.
Choose a Method Before You Start
All four methods below use tools that come with Windows and Excel, so there’s nothing to install and no macros to enable. They differ in what ends up in your sheet and whether you can refresh it later.
| Method | Best for | Gives you | Refreshable |
|---|---|---|---|
| Copy as path | A one-off list from one folder | Full paths, which you trim to names | No |
| Power Query (From Folder) | A list you’ll update, or one that includes subfolders | Name, extension, dates, folder path | Yes |
| Command Prompt (dir) | A plain text list you can paste anywhere | Names only, or full paths with subfolders | No (run it again) |
| PowerShell (Get-ChildItem) | Names with size and last modified date in a CSV | Any file property you pick | No (run it again) |
The examples use one scenario: Marcus keeps scanned invoices in C:\Scans\Invoices 2026, a folder with about 340 PDF files named like inv-0001.pdf, and he wants the names in column A of a workbook so he can mark which ones have been paid.
Quick List: Copy as Path and Paste Into Excel
This takes about a minute and works in any version of Excel. You copy full paths from File Explorer, then remove everything except the name.
- Open the folder in File Explorer.
- Press Ctrl+A to select every item, or click the first file and Shift+click the last to select a range. Ctrl+click adds or removes single files.
- Right-click one of the selected files and choose Copy as path. On current Windows 11 builds the menu also shows the shortcut Ctrl+Shift+C next to it. If you don’t see Copy as path, select Show more options (or press Shift+F10) to open the full menu.
- In Excel, click cell A2 and press Ctrl+V. Each file lands in its own row, as a full path wrapped in quotation marks, such as “C:\Scans\Invoices 2026\inv-0001.pdf”.
Ctrl+A also selects any subfolders in the folder, and their paths get pasted too. If you only want files, sort the folder by Type first so the folders group together, and leave them out of the selection.
Remove the Quotes and the Folder Path With Find and Replace
This changes the pasted cells in place, so it’s the fastest cleanup when you don’t need the paths afterward.
- Select column A and press Ctrl+H.
- In Find what, type a single quotation mark (“). Leave Replace with empty and choose Replace All.
- In Find what, type an asterisk followed by a backslash (*\). Leave Replace with empty and choose Replace All. The asterisk is a wildcard, so this removes everything up to and including the last backslash, leaving inv-0001.pdf.
Or Keep the Paths and Pull the Name With a Formula
Formulas leave the original paths in column A, which is handy if you later want a link to each file. Remove the quotation marks first (step 2 above), then put one of these in B2 and fill it down.
In Excel for Microsoft 365 and Excel 2024, use =TEXTAFTER(A2,"\",-1). The TEXTAFTER function returns the text after a delimiter, and the -1 tells it to count from the end, so it takes everything after the last backslash. To drop the extension as well, wrap it: =TEXTBEFORE(TEXTAFTER(A2,"\",-1),".",-1) returns inv-0001.
Excel 2021, 2019 and 2016 don’t have TEXTAFTER (you’ll see #NAME?). Use this instead:
=MID(A2,FIND("|",SUBSTITUTE(A2,"\","|",LEN(A2)-LEN(SUBSTITUTE(A2,"\",""))))+1,260)
It counts the backslashes, swaps the last one for a pipe character (which Windows doesn’t allow in file names, so it can’t collide with a real one), and returns everything after it. For C:\Scans\Invoices 2026\inv-0001.pdf, there are three backslashes, the third becomes a pipe, and the result is inv-0001.pdf.
When the names look right, copy column B and use Paste Special > Values if you want plain text that no longer depends on column A.
Refreshable List: Import the Folder With Power Query
Power Query is built into Excel for Microsoft 365, Excel 2024, 2021, 2019 and 2016. It reads the folder directly and returns one row per file, including files in subfolders, along with columns such as Extension and Folder Path. When files are added or removed, one refresh updates the sheet. Microsoft describes the connector on its page about importing data from a folder.
Before step 4: the dialog offers Combine buttons. Combine merges the contents of the files into one table, which is meant for a folder of matching CSV or Excel files, not for a list of names. Choose Transform Data.
- Open a blank workbook and go to Data > Get Data > From File > From Folder.
- Select Browse, pick the folder (C:\Scans\Invoices 2026 in the example), and confirm.
- A preview lists the files with their details. Check that it shows the files you expect.
- Select Transform Data. The Power Query Editor opens.
- Click the Name column header. Ctrl+click any others you want, such as Date modified or Folder Path.
- On the Home tab, choose Remove columns > Remove other columns. This drops the Content column, which holds each file’s data and would make the query slower.
- Optional: use the filter arrow on Extension to keep one type, or on Folder Path to leave out a subfolder.
- Choose Close & Load on the Home tab. Excel creates a new sheet with the list as a table.
To update it later, go to Data > Refresh All. New files appear and deleted ones disappear. If you type notes in a column next to the table, keep in mind that a refresh can reorder rows, so notes typed beside the table may no longer line up with the right file. For a payment tracker like Marcus’s, copy the names into a separate sheet once and add your notes there, or keep notes in a separate table matched by file name.
File extensions in the Extension column may be stored as typed on disk, so a folder with both .pdf and .PDF files needs both ticked in the filter.
Plain Text List: Use the dir Command
Command Prompt’s dir command writes a bare list of names to a text file, which you can paste into Excel or any other program. If you haven’t used it before, see how to open Command Prompt in Windows 11.
- Open the folder in File Explorer, click the address bar, type cmd and press Enter. Command Prompt opens already pointed at that folder. (From an ordinary Command Prompt window, use
cd /d "C:\Scans\Invoices 2026"instead; the /d switch changes the drive as well as the folder, which matters when the folder is on D: or a USB drive.) - Type this and press Enter:
dir /b /a:-d /o:n > ..\filelist.txt - Go up one folder (to C:\Scans in the example) and open filelist.txt. Press Ctrl+A, then Ctrl+C.
- Click A2 in Excel and press Ctrl+V. Each name goes into its own row.
Here’s what each part does, from Microsoft’s dir reference:
/bprints a bare list with no header, dates or sizes./a:-dleaves out folders. Microsoft says you need /a:-d and /b together when you redirect output to a file and want only file names./o:nsorts by name. Use /o:d for oldest first, /o:-d for newest first, or /o:s for smallest first.> ..\filelist.txtsaves the output one folder up. Writing it into the same folder would put filelist.txt in its own list.
To include subfolders, add /s: dir /b /s /a:-d > ..\filelist.txt. With /s, each line is a full path rather than a name, so use the Find and Replace or formula steps above to trim it. Because /a with an attribute shows files regardless of whether they’re hidden, the list can also include hidden files such as desktop.ini; delete those rows if they appear.
If you’d rather import than paste, use Data > Get Data > From File > From Text/CSV in Excel and pick filelist.txt. More on how Excel treats text and CSV files is in this explainer on opening CSV files in Excel.
Names, Sizes and Dates: Use PowerShell
When the list needs more than names, PowerShell can export any file property to a CSV that Excel opens with proper columns. Windows 11 includes Windows PowerShell 5.1; open it by searching for PowerShell from Start. Paste this as one line, changing both paths to match yours:
Get-ChildItem -LiteralPath "C:\Scans\Invoices 2026" -File | Select-Object Name, Length, LastWriteTime | Export-Csv -Path "C:\Scans\invoice-list.csv" -NoTypeInformation -Encoding UTF8
- Get-ChildItem -LiteralPath “…” -File lists only files (no folders) in that exact path. LiteralPath treats the path as typed, so brackets or other special characters in folder names don’t get read as wildcards.
- Select-Object Name, Length, LastWriteTime picks the columns: file name, size in bytes and last modified date. Divide Length by 1024 in Excel for kilobytes, or by 1048576 for megabytes.
- Export-Csv -NoTypeInformation writes the CSV without a #TYPE line at the top. Windows PowerShell 5.1 adds that line unless you include the flag; PowerShell 6.0 and later leave it out by default, so the flag is harmless there.
- -Encoding UTF8 keeps accented and non-English characters in file names readable.
Useful variations, all documented on Microsoft’s Get-ChildItem reference:
- Add
-Recurseafter-Fileto include subfolders, and addFullNameto the Select-Object list so you can tell which folder each file came from (FullName is the file’s full path). - Add
-Filter *.pdfto list only one type. Filter only accepts one pattern and supports the * and ? wildcards. - Hidden files are skipped by default. Add
-Forceif you need them included.
Open the CSV in Excel, or import it with Data > Get Data > From File > From Text/CSV so you can check the column types before loading. If you’ve installed PowerShell 7 (see updating PowerShell on Windows 11), the command also works, but there UTF8 means UTF-8 without a byte order mark, so accented names may look wrong when you double-click the CSV. Use -Encoding utf8BOM in PowerShell 7 instead; Microsoft’s Export-Csv page lists both options.
Fix Common Problems With the List
- Every name still has quotation marks. Copy as path always adds them. Run Find and Replace on a single ” with nothing.
- TEXTAFTER shows #N/A. The cell has no backslash, usually because it’s blank or already trimmed. Add a fallback as the last argument, for example
=TEXTAFTER(A2,"\",-1,,,A2), to return the cell’s contents instead of an error. - filelist.txt appears in its own list. The output file was written into the folder being listed. Delete that row, or rerun the command with the ..\ path shown above.
- Files in subfolders are missing, or showing when you don’t want them. Copy as path and dir without /s only read the top folder. Power Query always includes subfolders, so filter the Folder Path column to remove them.
- Accented or non-English names look wrong in filelist.txt. Command Prompt output can lose some characters when it’s redirected to a file, so use the PowerShell method with -Encoding UTF8 (utf8BOM in PowerShell 7) instead.
- The order doesn’t match File Explorer. File Explorer sorts numbers inside names by value (file2 before file10), while Excel sorts text character by character (file10 before file2). Pad numbers with leading zeros in your file names, or sort by a separate column.
- Power Query loads slowly. The Content column is still in the query. Open the query, remove it, and close and load again.
File List Problems and Fixes
Can I make each file name a clickable link?
Yes, if you keep the full path. With the path (no quotes) in A2 and the name in B2, =HYPERLINK(A2,B2) shows the name and opens the file when clicked. Links break if the files are moved or the workbook is opened on a PC without access to that folder.
Does the Power Query list update by itself?
Not unless you set it to. By default it changes only when you choose Refresh All, which means you control when the list changes. To change that, open Data > Queries & Connections, right-click the query, choose Properties, and on the Usage tab tick Refresh data when opening the file or Refresh every and a number of minutes.
Will pasting copied files into Excel give me their names?
No. Selecting files and pressing Ctrl+C copies the files themselves, not text. Use Copy as path, which puts the paths on the clipboard as text.
Can I combine lists from several folders?
Point Power Query at the parent folder, which pulls in every subfolder, then filter Folder Path to the ones you want. With dir, run the command in each folder and paste the results one under the other. If those folders contain CSV files you want merged rather than listed, see how to merge CSV files into one file.
Start with Copy as path if you need the list once today. If you’ll be checking the same folder again next month, set up the Power Query version now, since refreshing it takes one click.

Matthew Burleigh is the founder, head writer, and editor of Solve Your Tech, which he launched in 2012. He has written technology tutorials since 2008 and worked in IT since 2003, including small-business support, IT management, and consulting. He holds Bachelor’s and Master’s degrees in Computer Science from Arizona State University.
Matthew writes practical guides for Windows, iPhone and iPad, Microsoft Office, Outlook, Google apps, and Android. Solve Your Tech’s guides are checked step by step against the device or app maker’s own documentation and tested on his own devices whenever he has the hardware or software, with clear steps, sources, and update dates.
Read more about Matthew and how Solve Your Tech writes and updates its guides, or report a correction.