The Power Query tool can be used to export .xlsx and .txt file inside a folder and subfolder list to Excel.

Step 1 – Choose a Folder from the Data Tab
- Go to the Data tab and select the From Folder option from the Get Data feature.

- Select the folder to export from local storage and click Open.

Read More: Export Folder Structure to Excel
Step 2 – Import Data to Worksheet
- A preview window will open, click the Load To option.

- Import Data window will pop-up, input the cell location for inserting data and click OK.

Step 3 – Editing Data in Power Query Editor
- Edit the exported data by clicking the Edit option from the Query feature.

- When selecting multiple columns, choose Remove Columns from the Manage Columns option to delete columns.

- You can make a duplicate of the column from the Duplicate Column option by choosing the folder path column.

- Split the column by clicking the By Delimiter option from the Split Column

- In the pop-up window, choose the Custom option from the drop-down list.
- Input a delimiter (\), choose Columns from the Advanced Options, and enter a column number. Depending on the number of columns you need, enter the desired number.
- Click OK.

- The folder and subfolder lists are split.
- Click on Close and Load.

- The folder and subfolder list are successfully exported to Excel.

How to Show Folder and File Lists of a Certain Path in Excel
The Web browser can be used to show folder and file lists for a certain path.

- Open the folder and copy the folder path.

- Open the web browser and paste it in the Address bar and Press the ENTER

- The file lists will be displayed inside your browser.
- Select the lists, press CTRL+C to copy.

- Open your Excel workbook and paste the copied list.

Frequently Asked Questions
- Can I export a folder and subfolder list to Excel on a Mac?
Yes, it is possible to export a folder and subfolder list to Excel on a Mac by using the Terminal application to generate a list of files and folders in the desired directory, and then copying and pasting that list into an Excel worksheet.
- What information can be exported to Excel from a folder and subfolder list?
The information that can be exported to Excel from a folder and subfolder list includes file name, size, date created, date modified, and other relevant information.
Download Practice Workbook
<< Go Back to Power Query Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!


What a great page Wasim!
I didn’t see it, but I have a large directory that has recipes. In that recipe directory there are dozens of sub directories such as fish, vegetables, appetizers, etc. I have followed your instructions to import that recipes directory, and it’s great! However, is there a way to import the recipes directory, and have it separate all the subdirectories into individual sheets or something like that? It’s great what I have, but it currently has all the files in all the subdirectories in a long list. I could cut and paste manually, but I was just curious if you know a way to automate that somehow, if that makes any sense?
Again, GREAT page!
Charles Bowen
Hello Charles,
Thanks for your kind words—really glad the method worked for your recipe folders!
Yes, what you’re asking is possible, but it does require a bit of automation beyond the basic method shown in the article. Since the current approach lists everything in one sheet, you’d need to use VBA (macro) to split the results by subfolder.
Here’s the idea in simple terms:
1. After importing the full list (with folder paths),
2. You can use a VBA script to:
2.1. Identify each unique subfolder (like Fish, Vegetables, Appetizers, etc.)
2.2. Automatically create a new worksheet for each one
Filter and copy the relevant files into their respective sheets
If you prefer a non-VBA workaround, you could:
1. Use Excel Filters or Pivot Tables based on the folder path column
2. Or use Power Query to group/split data by folder (more dynamic and refreshable)
But for fully automatic sheet creation, VBA is the most efficient option. You can use this VBA macro after importing the folder/subfolder list into Excel.
Just change this line if your folder path is not in column A:
folderCol = 1
For example, use folderCol = 2 if the folder path is in column B.
Regards,
ExcelDemy