If you want to create a folder in OneDrive using Power Automate, you’re out of luck. There’s no action to do it, and, frankly, it’s pretty strange that Microsoft didn’t include it in the actions. It’s not like Microsoft doesn’t allow us to create folders in SharePoint using the “Create new folder” action. But, it’s still an idea, and it’s on Microsoft’s radar, so if you want this to become an action, please go to the idea section of the community and vote.
Microsoft doesn’t tell us directly, but OneDrive for Business is a glorified SharePoint Document Library (more or less), but the point stands. If we can do it in SharePoint, why not on OneDrive for business?
I don’t have the answer to this, but I have a simple solution.
We can create files
Although we cannot create folders, we can create files using the “Create file” action. One of the indirect benefits of using it is defining the path.
But what happens if we define a folder that doesn’t exist. For example:
We have an empty folder, and we want to create a folder with a draft text file in the “DRAFT” folder. Here’s the Flow to do it:
Let’s run the Flow and see what happens.
Finally, we can get our file and a “free” folder.
How about multiple folders. Let’s imagine creating the “DRAFT” folder and the “IMAGES” inside it. Taking a step further to prove the point, let’s add another level. Inside the “IMAGES,” we’ll create a “TO PROCESS” folder. So we’re making the “IMAGES” and “TO PROCESS.”
Here’s the Flow:
And here’s the final result:
So we can create not only a folder but an entire hierarchy. With this, we can work, so let’s look at the workaround.
The workaround
So with what we got in the previous chapter, we have a potential strategy. We can try to do it as follows:
- Create a file in the folder or set of nested folders
- Delete the file that we created.
It’s not at all critical of the file, extension, structure. We must have a file to create the folder structure.
It’s simple, and as a result, we’ll have the folder structure that we want. So let’s look at how to do it:
First, let’s empty the folder to get the total result:
And after we run the Flow, we get:
Awesome 🎉.
Final thoughts
Although we don’t have an action to create a folder in OneDrive, we can have a nice workaround and create a folder hierarchy in the process.
Photo by Savannah Wakefield on Unsplash
Although that is a workaround for creating a folder, if your use case calls for cleaning up afterward, you would want to delete all files that had been created AND delete the folder. Does deleting all the files remove the folder?
Thank you for this.