Power Query Problems

List Files and Subfolders with Excel Power Query

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 870 views

Question details

Create an Excel listing of files and subfolders beneath a parent folder, including names, extensions, creation dates, and full paths.

List All Files and Subfolders with Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
The user wants a refreshable folder inventory without manually entering each item or requiring administrator access.
Observed behavior
The desired result is a table of files and subfolders that can be refreshed when folder contents change.
Before you start

Identify the full path of the parent folder and confirm that your account can read it and its subfolders. Power Query cannot list locations your account cannot access.

Solution 1Recommended

List files and all subfolders with a recursive Power Query

Use a recursive query when the inventory must include folder entries, including empty subfolders.

The standard From Folder connector lists files recursively, but it does not provide a separate row for every subfolder. This query uses Folder.Contents to include both files and folders.

1
Create a blank query

In Excel, select Data > Get Data > From Other Sources > Blank Query.

2
Open Advanced Editor

In the Power Query Editor, select Home > Advanced Editor and replace the existing code with the following: let GetItems = (path as text) as table => let Items = Folder.Contents(path), Folders = Table.SelectRows(Items, each Value.Is([Content], type table)), Nested = List.Transform(Table.ToRecords(Folders), each @GetItems([Folder Path] & [Name])), Combined = Table.Combine({Items} & Nested) in Combined, Source = GetItems("C:\ParentFolder"), AddType = Table.AddColumn(Source, "Item Type", each if Value.Is([Content], type table) then "Folder" else "File", type text), AddFullPath = Table.AddColumn(AddType, "Full Path", each [Folder Path] & [Name], type text), Result = Table.SelectColumns(AddFullPath, {"Name", "Item Type", "Extension", "Date created", "Folder Path", "Full Path"}) in Result

3
Set the parent folder

Replace C:\ParentFolder in the code with your parent folder's full path, keeping it inside the quotation marks. Select Done.

4
Load and refresh the list

Review or filter the columns in Power Query Editor, then select Home > Close & Load. To update the inventory later, select Data > Refresh All in Excel.

List files and all subfolders with a recursive Power Query
Folder access: Administrator access is not inherently required, but the query can fail if your account cannot read a subfolder.
Free Microsoft Office alternative

Review Excel Folder Inventories in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for opening and reviewing Excel workbooks. It supports common Office formats for easier migration, though it does not fix Microsoft Excel Power Query issues.

Review and filter a loaded folder inventory in a spreadsheetCompatible with Microsoft Excel XLS and XLSX formatsFamiliar spreadsheet interface for an easier transitionFree and lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Does Excel's From Folder connector include files in subfolders?

Yes. Select Data > Get Data > From File > From Folder and choose the parent folder. The resulting file list includes files in its subfolders.

Will empty subfolders appear in the standard file list?

No. The standard From Folder connector lists files, not separate rows for empty folders. Use the recursive Folder.Contents query above to include folder entries.

How do I update the list after adding or removing files?

In Excel, select Data > Refresh All to rerun the query and load the current folder contents.

Do I need administrator access to list the folder contents?

Not necessarily. Your account needs permission to read the parent folder and the subfolders being queried; inaccessible locations can cause the query to fail.