Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

Power Query: Get a list of file names from folders and sub-folders

Author Xiaoyang Last modified

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:

In Excel 2019 and Office 365, click Data > Get Data > From File > From Folder

2. In the opened Browse window, choose the folder contains the files that you want to get the files names from, see screenshot:

choose the folder contains the files to get the files names from

3. Then, click Open button, a preview list of documents opens as below screenshot shown:

 a preview list of documents opens

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:

 click the expand icon in the Attributes column to shown a list of additional columns

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:

 delete the columns by right-clicking the column, and click Remove

7. After getting the attribute columns you need, please click Close & Load > Close & Load, see screenshot:

 click Close & Load > Close & Load

8. Now, all the data about the files are loaded into a new worksheet as below screenshot shown:

all the data about the files are loaded into a new worksheet

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.

click Data > Refresh All, to refresh the file names

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:

 change argument to list the file names from the folder only

And now, only the file names and sub-folder names in the specific folder are listed, see screenshot:

only the file names and sub-folder names in the specific folder are listed


🔍 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

List All Files in a Folder by Kutools

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

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.

Excel Word Outlook Tabs PowerPoint
  • 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