Automation is key when it comes to automatic documentation, and creating folders and templates automatically is the way to get things prepared and done for you. Create a new folder is quite a simple task, but think about more complex nested folders and other operations that can be done automatically. SharePoint’s create new folder action helps with this.
Where to find it?
Although you can navigate in the structure, it’s always better to search for what you want. In our case, we want SharePoint:
And then pick the “create new folder” action.
Power Automate tends to save the most common actions on the main screen, so check there before going through the full hierarchy. Also, you can use the search to quickly find it.
Usage
To create a new file you need 3 things:
- The site address – Where will you create it.
- A list or library inside that site – Since you can have multiple both, you need to choose the one you want.
- The path to the folder
The last one holds a few tricks, so let’s explore them.
It doesn’t need to be only one folder.
If you want to create a whole folder structure that doesn’t exist, you can create the full path, and it will be created for you so if you’ll have multiple new folders created. For example:
You’ll get:
It will complete paths that are missing
If you have a path like above and want to create a fourth or fifth level, you can define the path, and the “create new folder” action will only create the folders that don’t exist. If there are files inside those folders, Power Automate won’t touch these.
Build your own path
Completing the above example, let’s move the path outside the “Create new folder” action.
Let’s run, and we’ll get the “Fourth Level” as expected.
Limitations
This is not a limitation per se, but you should be aware of it. If you use the “Create new folder” action and try to move or create files in the next action, your Flow may fail. This is because, although SharePoint is quite fast creating folders, it’s not instantaneous. If you get an error, a workaround adds a small delay using the “delay” action. It’s not an elegant solution, but in this case, SharePoint may need a bit extra time to create the folder structure.
Recommendations
Here are some things to keep in mind.
Name it correctly
The name is super important in this case since we’re getting the file by either calculating the path or having a defined static one. Always build the name so that other people can understand what you are using without the need to open the action and checking the details.
Always add a comment.
Adding a comment will also help to avoid mistakes. Indicate where the path comes from, for example, if it’s calculated and how. It’s important to enable faster debugging when something goes wrong.
Always deal with errors.
Files may change places and names, so what’s true now is not a few weeks from now. Have your Flow fail graciously when the file doesn’t exist and notify someone that the file is missing. It’s horrible to have failing Flows in Power Automate since they may go unlooked for a while or generate even worse errors.
Back to the Power Automate Action Reference.
Photo by Christina Winter on Unsplash
Hi Manuel,
Many thanks for this post. This is by far the closest I’ve come to fixing my problem.
I got it working using your above method but I’ve got to make a whole host of folders and sub-folders.
I’ve tried putting everything into a SharePoint list and using your PATH as follows
After using get item to get the list details
/Reports/Area (variable from list)/Team (variable from list)/Venue (variable from list)
I initially tried it with just /Reports/Area and it created just one folder, seemingly picking a team at random.
i tried using the Create Folder action with apply to each unique ID on the list but which ran successfully but nothing happened.
In short, how do I apply your above code to a pre-determined list so I can create many folders in one go.
Many thanks
Mat
Hi Mathew,
We can solve it by doing the following:
,'##1##', )
,'##2##', )
1. Create a variable with the path and the variables with a sequence of unique characters. The characters are not important since they are placeholders used in the next steps. For example
/Reports/Area ##1##/Team (variable from list)/Venue ##2##/
2. In the “Apply to each” action have a “Compose” action that genrates the final path by replacing the values.
replace(
3. Do the same for the second variable from the list like this:
replace(
4. use the create folder action to create the folders in one step.
You can do this for all necessary “levels” by adding more placeholders.
Can you please give it a go and let me know if it works?
Cheers
Manuel
Hi I need to create folders and subfolders in same action in sharepoint library.