September 24, 2021

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.

I wrote an article about how to create nested folders and copy templates automatically all done using Power Automate and SharePoint. The whole process takes you 15 minutes and saves you hours of creating folders and copying files.

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.

Pro Tip
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:

  1. The site address – Where will you create it.
  2. A list or library inside that site – Since you can have multiple both, you need to choose the one you want.
  3. 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.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Christina Winter on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: