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

Community site session details

Session Id : 2A3xS6o3ctf7ZtLQCAV0Wt
Power Automate - Building Flows
Suggested answer

Automatic Sub folder structure when a new folder is created in a document libary

Like (0) ShareShare
ReportReport
Posted on 25 Jan 2025 20:00:07 by 2
Hallo,
i would like to create an automated cloud flow in Power Automate.
When a folder is created in my document library, I want to check if the newly created item is a folder, if so, I want to create 5 subfolders in this newly created folder: Images, External communication, Internal communication, Documents, Supplier claim
I managed to get the flow to create the subfolders in the new folder. However, a short time later, the same 5 folders are created AGAIN on the first level on which I originally triggered the flow with the new folder.
 

 
these folders are correct
 
 
And then the ssame folders are created on the first layer again besides my created folder "Testfolder"
 
Can someone tell what am I doing wrong or what is missing?
 
It seems that the flow is running several times even if it has been triggered once.... (see attached csv)
 
Thanks in advance for any help given =)
 
I have the same question (0)
  • ON-25011933-0 Profile Picture
    2 on 26 Jan 2025 at 13:13:24
    Automatic Sub folder structure when a new folder is created in a document libary
    Hi NsL Coder, thanks for your reply!
     
    Regarding your example:
     
    • Folder Top Folder is created
      • flow will create Subfolder 1 inside Top Folder
      • flow will create Subfolder 2 inside Top Folder
     
    These folders below won't be created by the flow. It's fine so far. In my manually created folder the structure is exactly as expected. (part1)
     
    • Subfolder 1 is created (by flow)
      • flow will create Subfolder 1 insider Subfolder 1
      • flow will create Subfolder 2 insider Subfolder 1
    • Subfolder 2 is created (by flow)
      • flow will create Subfolder 1 insider Subfolder 1 
      • flow will create Subfolder 2 insider Subfolder 2
     
    But the following happens:
     
    On top level:                             On 2nd level:
     
    Subfolder 1 is created
                                                        Subfolder 1-5
    Subfolder 2 is created
                                                        Subfolder 1-5
    Subfolder 3 is created
                                                        Subfolder 1-5
    Subfolder 4 is created
                                                        Subfolder 1-5
    Subfolder 5 is created
                                                       Subfolder 1-5
     
    Inside each folder (Subfolder 1 to 5) is created again. But it stops always on 2nd lvl - no endless loop I guess.
     
    But I couldn't figured out how to get the flow stop directly after part 1.
     
     
    I'm just a very beginner in creating flows with Power automate.
    So my problem is I don't know what kind of conditions or steps are need in addtion to avoid the creation on first level again...
     
     
    If you have an idea, you are very welcomed to let me know.
    =)
     
    Best Regads
    Olli
  • Suggested answer
    NsL Coder Profile Picture
    475 Super User 2025 Season 2 on 26 Jan 2025 at 05:49:50
    Automatic Sub folder structure when a new folder is created in a document libary
    the immediate problem is recursive behavior of your flow. You will need to do more conditions to avoid...
     
    So for example:
    • Folder Top Folder is created
      • flow will create Subfolder 1 inside Top Folder
      • flow will create Subfolder 2 inside Top Folder
    • Subfolder 1 is created (by flow)
      • flow will create Subfolder 1 insider Subfolder 1
      • flow will create Subfolder 2 insider Subfolder 1
    • Subfolder 2 is created (by flow)
      • flow will create Subfolder 1 insider Subfolder 1 
      • flow will create Subfolder 2 insider Subfolder 2
    so on and so forth, never ending...(well until create folder fail due to folder too deep or path too long.)
     
    I'm going to assume you do not want ANY folder creation result in the 5 subfolders created, so you need to have more conditions to stop this from happening. For example, maybe you only want subfolders to be created when folder created is at a certain folder level. Or maybe you condition that if the folder created is not the 5 named subfolders.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 626 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 374 Moderator

#3
Expiscornovus Profile Picture

Expiscornovus 284 Most Valuable Professional

Last 30 days Overall leaderboard
Loading started
Loading complete