web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to implement recur...
Power Automate
Unanswered

How to implement recursive folder processing in Power Automate to handle dynamic folder depths?

(0) ShareShare
ReportReport
Posted on by

Hi all,

I am working on a Power Automate solution to mirror the contents of a network drive (using the File System connector via on-premises data gateway) into a SharePoint document library.

The folder I want to sync (X:\TEST) contains multiple levels of subfolders, and the depth of the folder structure can increase in the future (currently about 5-6 levels).

My current flow uses the File System → List files in folder → loop through items → conditionally create folders and upload files to SharePoint. This works for one level, but I want to make it recursive to handle any future folder depth dynamically, without manually duplicating the “List files” and “Apply to each” actions for each subfolder level.

I tried using a child flow that calls itself recursively (Run a Child Flow → same child flow), but Power Automate gives an error saying the child flow must end with a response action.

 

My key question

  • Is there a Power Automate-supported way to create a recursive flow (parent → child or self-recursive) for dynamically traversing unknown folder depths?
  • Or is the only solution to manually repeat the folder listing logic a fixed number of times?
  • Are there better ways to achieve this within Power Automate ?
 
Appreciate any best practices or examples from anyone who has solved a similar problem.
 

Thanks in advance!

Parent Flow.png
Child Flow.png
Categories:
I have the same question (3)
  • WillPage Profile Picture
    2,337 Super User 2026 Season 1 on at
    Doing this kind of thing in Power Automate can be pretty fraught but you could try using the folder path property of the List files in your Create file action.

    It's been a while since I used the on prem file system action and I don't have one to test with right now, so I don't know what the Path property looks like, but assuming for each file it's like
     
    X:\TEST\Folder1\Folder2\Folder3\File.docx

    You can use replace within a Select to eliminate the bits of the path you don't want, e.g replace(item()?['Path'],'X:\TEST','') assuming the column of the File system response is called Path (it may be something else).
     
    Similar with the file name: replace(item()?['Path'],item()?['FileName'],'') where item()?[FileName'] references the file name column from the array, whatever that may be called.
     
    Ultimately you want the resulting array property to be just \Folder1\Folder2\Folder3\ which you can then use in the path of your Create File action for SharePoint. It should create the folder structure if it don't exist, or just create the file there if it does already.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 376

#2
Valantis Profile Picture

Valantis 361

#3
David_MA Profile Picture

David_MA 294 Super User 2026 Season 1

Last 30 days Overall leaderboard