Power Query: Get a list of file names from folders and sub-folders
In our previous List All File Names From A Folder And Sub-Folders tutorial, you can list all file names from a folder and the sub-folders by some basic methods, such as formula, VBA code, etc. In this article, I will introduce an amazing feature – Power Query, with this feature, you can list all files from a folder and sub-folders dynamically. After getting the filenames, when you delete or insert new files, the file name list will be refreshed automatically.
Get a list of file names from folders and sub-folders with Power Query
To achieve this task by using the Power Query feature, please do with the following steps:
1. In Excel 2016 and Excel 2021, please click Data > New Query > From File > From Folder, see screenshot:
Note: In Excel 2019 and Office 365, you should click Data > Get Data > From File > From Folder, see screenshot:
2. In the opened Browse window, choose the folder contains the files that you want to get the files names from, see screenshot:
3. Then, click Open button, a preview list of documents opens as below screenshot shown:
4. And then, click Transform Data to open the Power Query Editor window, the file attributes are displayed in the window.
5. If you want to get other attributes, such as file size, please click the expand icon in the Attributes column, it will show you a list of additional columns, select the columns that you want to have in the data, and uncheck the rest. Here, I will check Size option, see screenshot:
6. You can also delete the columns that you don’t need. In the Power Query Editor window, select the column you want to delete, right-click the column, and click Remove. See screenshot:
7. After getting the attribute columns you need, please click Close & Load > Close & Load, see screenshot:
8. Now, all the data about the files are loaded into a new worksheet as below screenshot shown:
Tips:
1. If you need the file names changed dynamically when you delete existing files or insert new files into the folder, you just need to click Data > Refresh All, and the file name list will be refreshed to the newest list.
2. With above steps, all files in folder and its sub-folders are listed. If you want to list the file names from the folder only (excluding the sub-folders), you just need to change the Folder.Files to Folder.Contents into the formula bar of the Power Query Editor window, see screenshots:
And now, only the file names and sub-folder names in the specific folder are listed, see screenshot:
🔍 Quickly List All Files in a Folder — Including Subfolders!
With just one click, Kutools for Excel’s Filename List feature allows you to instantly generate a complete list of all files in a folder — including hidden files and subdirectories! 🎯 Save time and boost productivity — no more manual file tracking! Try Kutools for Excel and get organized in seconds!
✅ Filter by file type (e.g., Excel, Word, etc.) for focused file management | ✅ Include subdirectories and hidden files to support in-depth file listing |
✅ Automatically generate clickable hyperlinks — open files instantly | ✅ Display file size in bytes, KB, etc. for full detail control |
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in