While working on an Employee Leave Request App application, I had to delete the empty folders in the document library using Power Automate. Unfortunately, the Delete folder action is not present in Power Automate.
After some research, I found two ways to delete a folder in the SharePoint document library using Power Automate. Such as:
- Delete SharePoint folders using Power Automate Send an HTTP request to SharePoint action
- Delete SharePoint folders using Power Automate Delete Item action
In this tutorial, I will cover how to delete SharePoint folders using Power Automate. Also, I will explain, below mentioned topics:
- Delete a SharePoint document library folder If it exists with a specific name
- Delete multiple SharePoint library folders using Power Automate
- Delete empty folders in the SharePoint library using Power Automate
Delete Specific SharePoint Document Library Folder using Power Automate
I have a SharePoint document library [Payroll Records], where different types of files and folders are present. Within the mentioned document library [Payroll Records], I wanted to delete a specific folder named ‘Marketing‘.
SharePoint Document Library:

Note:
Unfortunately, Delete folder action is not present in Power Automate SharePoint connector. Instead, we can use the SharePoint Delete item action to remove folders from SharePoint document libarary.
Follow the instructions below to create a flow:
1. Browse https://make.powerautomate.com to open the Power Automate Home page -> Instant cloud flow -> Manually trigger a flow trigger, where we can run the flow with one button click.
2. Next, add Get folder metadata to get the folder ID of a specific folder. Configure the parameters:
- Site Address: Select the SharePoint site from the drop-down where your SharePoint library folders are present.
- File Identifier: Choose the folder you want to delete from the Open folder icon.

3. After that, take the Delete item action to remove the SharePoint library folder. Set the properties as below:
- Site Address: Choose the SharePoint site.
- List Name: Select a custom value to enter the library name.
- Id: Choose to add ItemId from the dynamic content of the Get folder metadata.
Important:
In Power Automate Delete item action, List Name parameter only displays all the lists that are present in the SharePoint site. We need give document library name as a custom value.

Now, the flow is ready. Click on the Save button. Test the flow manually.
4. When the flow runs successfully, you can see that the folder [Marketing] I showed above has been deleted from the SharePoint document library.
Refer to the image:

Delete Multiple Folders in SharePoint Document Library Using Power Automate
I will use the SharePoint document library [Payroll Records] with files and folders. I wanted to delete multiple folders in this document library.

Follow the steps below:
1. Create Instant cloud flow on the Power Automate -> Manually trigger a flow.
2. add the Get files [properties only] action to fetch all the documents from the SharePoint document library.
Set the parameters like Site Address and Library Name.

3. Then, add a Condition control action to fetch only folders from the SharePoint document library.
Set the given values:
| Choose Value | Operator | Choose Value |
| IsFolder | is equal to | true |

For each loop, the dynamic body/value of Get files (properties only) will be added.
4. Under the True branch, add the Delete item action. Set the required parameters:
- Site Address: Choose the SharePoint site where the document library is present.
- List Name: Enter the custom value [Provide library display name]
- Id: Add ID from the dynamic content of Get files (properties only) outputs.

Once the flow is ready, click on the Save button. Then, Test the flow.
5. You can see the flow will run successfully without generating any errors.

Output:
Go back to the SharePoint library and refresh the page. The library folders have been deleted.

This is how we can delete multiple folders in the SharePoint document library using Power Automate.
Delete Empty Folders in SharePoint Document Library Using Power Automate
For this example, I will take a SharePoint document library named [Budget Cost Files], which consists of files and folders. I wanted to eliminate all the empty folders in this SharePoint library.
See the SharePoint document library [Budget Cost Files]:

Important:
In Power Automate SharePoint connector, Delete folder action is not present. Instead, we can use Power Automate Send an HTTP request to SharePoint action.
Check out the steps:
1. Add button flow in Power Automate, where a user can trigger a flow by one click.
2. Next, add a Send an HTTP request to SharePoint action to get the folders from the SharePoint document library.
Configure properties:
| Parameters | Values |
| Site Address | Choose site from drop-down |
| Method | GET |
| Uri | _api/web/GetFolderByServerRelativeUrl(‘/sites/AllyFinancialBank/BudgetCostFiles’)/Folders |
| Headers | { “accept”: “application/json;odata=nometadata” } |
I have renamed the action to Get Folders.
Uri: _api/web/GetFolderByServerRelativeUrl('/sites/AllyFinancialBank/BudgetCostFiles')/Folders
Replace SharePoint document library name
3. After that, take Filter array action to filter the output of the previous action. Ensure to set the parameters:
- From: Add body(‘GetFolders’)?[‘value’] in the expression.
- Filter Query: Paste the code given below.
Click on Edit in advanced mode to insert the code.
and(equals(item()?['ItemCount'], 0), not(equals(item()['Name'], 'Forms')))Important:
In the above code, first part checks if the item count is equal to zero and second part check if folder name is not equal to Forms. Where, Forms is an internal folder in every document library that can not be deleted.

4. Then, add Apply to each action to loop through each folder coming from the output of the filter array.
- Select an output from previous steps: Select Body from dynamic content of Filter array.

5. Inside the loop, add one more Send an HTTP request to SharePoint action to delete the empty SharePoint document library folders.
Configure the required parameters:
- Site Address: Choose the desired SharePoint site
- Method: Select DELETE from the drop-down
- Uri: Insert the code placed below
_api/web/GetFolderByServerRelativeUrl('/sites/AllyFinancialBank/BudgetCostFiles/@{items('Apply_to_each')['Name']}')
File Name can be entered from the Expression tab.
Replace Site name,Library name
6. Now the flow created sucessfully. Click on Save. Then, click on Test. Run the flow manually.
7. Once the flow runs successfully, empty folders in the specific document library will be deleted.
After deleting empty folders [Budget Cost Files]:

Conclusion
I have discussed the following topics such as:
- Deleting a SharePoint-specific folder in Power Automate
- Deleting multiple SharePoint document library folders by Power Automate
- Delete all empty folders in SharePoint using Power Automate
You may also visit:
- Create Outlook Calendar Events Using Power Automate
- Delete File From SharePoint Using Power Automate
- Delete Files Older than 3 Years from SharePoint Document Library Using Power Automate
- Rename Subfolders in a SharePoint Document Library Using Power Automate
- Copy File From Network Drive to SharePoint Using Power Automate
- Delete All Items in the SharePoint List Using Power Automate
- Power Automate If Contains

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.