List Subfolders and Find Files by Path in Windows
Question details
List files and subfolders beneath a parent folder with their full paths, and identify the folder containing a specific file.

- Product
- Windows Command Prompt and Microsoft Excel Power Query
- Device & OS
- Windows
- Scenario
- A user wants to inventory a folder tree and locate a file without opening each subfolder manually.
- Observed behavior
- The desired result is a searchable list of full paths or a filtered table showing the file name and its folder path.
Copy the full path of the parent folder from File Explorer's address bar. Make sure you have permission to access the folders you want to search.
List full paths with Windows Command Prompt
Use this method to create a searchable text list of files and subfolders.
Open the Start menu, search for Command Prompt, and select it.
Enter dir /s /b "C:\Your\Parent\Folder" > "%USERPROFILE%\FileList.txt", replacing C:\Your\Parent\Folder with your parent folder path. Press Enter.
In File Explorer, enter %USERPROFILE% in the address bar and open FileList.txt in Notepad. Press Ctrl+F and search for the file name; its full path shows the containing folder.

Filter file paths with Excel Power Query
Use Power Query when you want to filter file names and folder paths in a table.
Review File Lists in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility for an easy transition. Use WPS Spreadsheets to review a file list after creating or importing it; WPS does not replace the Windows directory command or Excel's Power Query folder connector.

Frequently Asked Questions
How do I find which folder contains a file in the text list?
Open FileList.txt in Notepad, press Ctrl+F, and search for the file name. The folder path appears before the file name in each matching full path.
How can I include hidden and system items in the Command Prompt list?
Add /a to the command: dir /s /b /a "C:\Your\Parent\Folder" > "%USERPROFILE%\FileList.txt". You still need permission to access the folders.
Does Excel's From Folder connector list empty subfolders?
No. Data > Get Data > From File > From Folder returns files and their folder paths, rather than a separate list of empty subfolders.
What if multiple files have the same name?
In Notepad, use Ctrl+F to move through the matches and compare their full paths. In Power Query, filter the Name column and check the Folder Path column for each result.




