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 / Creating Sub Folders w...
Power Automate
Unanswered

Creating Sub Folders within a new folder

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Guys,

 

I am trying to utilise Power Automate to speed up a process. I am using Sharepoint for file storage in work and I am looking to create a flow that automatically creates 5 subfolders inside a new folder once it has been created. Is this possible/ how do i do this? I can't see any tutorials online. This is my first time using Power Automate so any guidance would be much appreciated!

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,868 Most Valuable Professional on at

    Hi @Anonymous,

     

    Yes, this would be possible by using an array and the create new folder action within an apply to each loop.

     

    Below is an example of that setup.

     

    1. Add Initialize variable action. Make it of type Array. You can use the following array as an example.

    [
     {
     "SubFolder": "Terms & Conditions"
     },
     {
     "SubFolder": "NDA"
     },
     {
     "SubFolder": "Questionnaires"
     },
     {
     "SubFolder": "SOW"
     },
     {
     "SubFolder": "Other docs"
     },
     {
     "SubFolder": "Terms & Conditions/Archive"
     }
    ]

    subfolderarray.png

     

    2. Add a Parse Json action. Use the SubFolders variable as content and the following Schema:

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "SubFolder": {
     "type": "string"
     }
     },
     "required": [
     "SubFolder"
     ]
     }
    }

    parsejson_subfolders.png

     

    3. Add a create new folder action. Use the subfolder dynamic content field in the folder path. This will put the action inside an apply to each loop. You can also add other parts to the folder path. In my example below I am using a LegalComplianceRootFolder variable.

     

    createsubfolderloop.png

     

    Hope this helps a bit?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, thanks so much for your help. I have followed these instructions and feel like I am getting somewhere but the flow does not work for me, I must be doing something wrong!

    So basically when I create a new folder in the Documents of the Sharepoint site, I need that new folder populated with 6 subfolders. Is there any other support or guidance you can give me?

     

    Many thanks!

  • Expiscornovus Profile Picture
    33,868 Most Valuable Professional on at

    Hi @Anonymous,

     

    That requirement is a bit tricky because you don't want to end up in a Power Automate flow loop 😁

     

    So, somehow we need to trigger the flow when a new folder is created but not trigger the flow ourselves when we create those 6 folders via our flow.

     

    I would probably say some additional trigger conditions would be the easiest. Below is an example of that setup.

     

    1. Add a When a file is created (properties only)

    dropfolderexample.png

     

    2. Add the following trigger conditions in the settings of that action. Make sure you add all 6 of your folder names from the array so they are excluded to trigger the flow. In my example I only added 2. The first condition is to make sure the created file is a folder.

    @triggerOutputs()?['body/{IsFolder}']
    @not(equals(triggerOutputs()?['body/{Name}'], 'NDA'))
    @not(equals(triggerOutputs()?['body/{Name}'], 'Terms & Conditions'))

    isfolder_excludecreatedfolders.png

     

    3. Add Initialize variable action. Make it of type Array. You can use the following array as an example.

     

     

    [
     {
     "SubFolder": "Terms & Conditions"
     },
     {
     "SubFolder": "NDA"
     },
     {
     "SubFolder": "Questionnaires"
     },
     {
     "SubFolder": "SOW"
     },
     {
     "SubFolder": "Other docs"
     },
     {
     "SubFolder": "Terms & Conditions/Archive"
     }
    ]

     

     

    subfolderarray.png

     

    4. Add a Parse Json action. Use the SubFolders variable as content and the following Schema:

     

     

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "SubFolder": {
     "type": "string"
     }
     },
     "required": [
     "SubFolder"
     ]
     }
    }

     

     

    parsejson_subfolders.png

     

    5. Add a create new folder action. Use the name of the original folder together with the subfolder dynamic content field in the folder path field. This will put the action inside an apply to each loop. 

    @{triggerOutputs()?['body/{Name}']}/@{items('Apply_to_each')['SubFolder']}

     

    createsubfolders_witoutloop.png

     

     

     

  • floor49 Profile Picture
    6 on at

    This is great and it almost works perfectly! Maybe someone can help me out with the following?.. I think I did every step and the subfolders are now created automatically when someone creates a folder.  The only problem I can't seem to solve is.. how to make sure the flow only gets triggered when a folder is created under the specified rootdirectory.. and not when a folder is created on a deeper level? 

     

     

     

  • jameela1 Profile Picture
    26 on at

    Hi, This is working perfectly but first time only working fine. In the second time creating the sub folders in outside of new folder. Can you please advise. 

     

    Thanks 

  • EmpireOfDave Profile Picture
    on at

    Hi! I just used the above guide and had the same issue, I got around it by adding a condition after Initialise Variable, with: Folder Path dynamic content, is equal to, NAME OF YOUR ROOT LIBRARY/

     

    @{triggerOutputs()?['body/{Path}']} equalTO 'YOUR LIBRARY NAME/'

     

    Then moved the Parse JSON and ApplyToEach loop inside the yes condition. The flow does still fire every time a folder is made, but it resolves to No on the condition with no actions. Someone smarter than me may be able to make this work inside a trigger condition, but I haven't managed it yet. This solution works fine for my needs however.

  • Nic-AF Profile Picture
    on at

    It's as straight forward as adding this in the trigger.

    @equals(triggerOutputs()?['body/{Path}'], 'THE LIBRARY')

     But I get why you didn't manage it.  It wasn't working at first when I tried.  Then later it worked.  I'm guessing there might be a delay for the trigger conditions to take effect, not sure.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 711

#2
Vish WR Profile Picture

Vish WR 691

#3
Haque Profile Picture

Haque 525

Last 30 days Overall leaderboard