Hi EXTERNAL Eswaraiah Devara (Apexon, SO/OPM26-IN),
Thank you for reaching out to us on the Microsoft Q&A forum.
To loop through all folders and subfolders in SharePoint, you can use Power Automate (formerly known as Microsoft Flow). Here’s a step-by-step approach:
Step-by-Step Points
Set Up Flow:
Go to Power Automate > Create > Automated Flow.
Choose a trigger (e.g., When an item is created or When a file is created).
Get Folder Metadata:
Add the Get Folder Metadata action.
Set it to the root folder in the desired document library.
List Folder:
Add the List Folder action.
Configure it with your site address and the folder path.
Loop Through Items:
Add an Apply to Each action using the output from the List Folder.
Inside this loop, add a Condition to check if the item is a folder.
Recursive Action:
If true (it's a folder), call List Folder again for the folder’s path.
Process Data:
Log or process folder and subfolder paths as needed (e.g., send emails, store in a database).
Kindly refer to the screenshots below.
Kindly refer to the screenshots below.
If you found the information helpful, we would greatly appreciate it if you could acknowledge it by selecting the Accept Answer & Upvote options.
Thank you.