In this Power Automate tutorial, we will discuss how to delete files from SharePoint using Power Automate or Microsoft Flow. We will see various examples on the Power Automate delete file from SharePoint.
And also we will discuss the below points:
- Power automate delete files in sharepoint folder
- Power automate delete all files in sharepoint library
- Power automate delete files older than
- Power automate sharepoint delete old files
- Power automate delete all files in onedrive folder
- Power automate delete files after a certain time
- Power automate delete files older than 30 days
- power automate delete files from recycle bin
Power Automate delete files in SharePoint folder
Here we will see how to delete files in SharePoint Folder using Power Automate or Microsoft Flow.
So here I have a SharePoint Folder in the library called Contract, so we will create a flow that will delete all files in the below folder.
Let’s see how to create a flow that will delete all files in the SharePoint Folder.
In Power Automate, select the Manually triggered Flow, then click on the Next step.
Now we will retrieve files from the SharePoint library, so select Get Files (Properties only) action. Then provide the site address and Library name.
Now From the SharePoint library, we will filter the folder, from which we want to delete the files. So click on the Next step and select Filter Array action, then in From field provide the value from dynamic content.
Then in value select the Folder path from dynamic content, the select operator is equal to and value provide the folder path i.e. Shared Documents/Contract/.
Now we will delete all files in the SharePoint Folder, so add an Apply to each action, then provide the body from the above step. Next click on Add an action and select Delete File action, the provide the site address, and in File identifier provide the below expression.
item()?['{Identifier}']
Now click on Save and run the flow Manually, you can see all files are deleted from the SharePoint Folder.
This is an example of power automate delete files in sharepoint folder.
Read Power Automate create table with examples
Power Automate Delete all files in sharepoint library
Here we will see how to delete all files in the SharePoint library using Power Automate.
I have a SharePoint library called Contract, so here we will see how to delete all files in the below SharePoint library.
In Power Automate, select the Manually triggered Flow, then click on the Next step.
To retrieve all files from the SharePoint folder, select Get Files(Properties only), then provide the site address and Library name.
Now we will delete all files present in the SharePoint library, so click on the Next step and select Delete FIle action. Then Provide the site address and File identifier from the dynamic content, which will automatically add Apply to each action.
Now click on Save and run the flow manually, you can see files get deleted from the SharePoint library.
This is an example of Power Automate delete all files in sharepoint library.
Read How to get days of month in Power Automate
Power Automate delete files older than
Here we will see how to delete files older than 7 days using power Automate.
I have a SharePoint library, called Contract, from this library we will delete all files that are older than 7 days based on Create date.
Let’s see how to create a flow that will delete files older than 7 days using Power Automate or Microsoft Flow.
In Power Automate, select the Manually triggered Flow, then click on the Next step.
Now we will retrieve files from the SharePoint library that are older than 7 days. so select Get Files(properties only). Then provide the site address, library name, and in Filter query write the below query
Created le 'fx(addDays(utcNow(),-7,'yyyy-MM-dd'))'
Once we get the file that is older than 7 days, now we can delete the file, so click on the Next step and select Delete File action than provide the site address, and file identifier from the dynamic content, which will automatically add the Apply to each action.
Now click on Save and run the Flow manually, you can see the files that are older than 7 days.
This is an example of Power Automate delete files older than.
Read How to convert word to pdf using Power Automate
Power Automate SharePoint delete old files
Here we will see how to delete old files in the SharePoint Folder using Power Automate.
So here we have a SharePoint Folder in the Document library called Saved Documents, from this folder we will delete the old files, that are older than 20 days.
In the Power Automate, select the Manually triggered Flow, then click on the Next step.
Next, we will retrieve the old files from the SharePoint Folder, so Select Get Files(properties only) action. Then provide the site address, Library name, and in the Limit entries to folder select the folder from which you want to delete old files. Then in the Filter query field add the below query:
Created le 'fx(addDays(utcNow(),-20,'yyyy-MM-dd'))'
Now we will delete files from that folder, so click on the Next step and select Delete File action, then provide the site address, and in File identifier from the dynamic content, that will automatically add Apply to each action.
Now click on Save and run the Flow manually, and you can see the 20-day old files are deleted from SharePoint Folder.
This is an example of Power Automate SharePoint delete old files
Power Automate delete all files in onedrive folder
Here we will see how to delete all files in the OneDrive folder using Power Automate and Microsoft Flow.
In the OneDrive we have a folder called Documents, so we will create a flow that will delete all files in the OneDrive Folder.
Let’s create a flow that will delete all files in OneDrive Folder using Power Automate or Microsoft Flow.
In Power Automate Select the Manually triggered Flow, then click on the Next step.
Now we will retrieve all files from that folder, so select List Files in Folder action, then provide the Folder path.
Next, we will delete files in the OneDrive folder, so click on the Next step and select Delete File action, the provide the File field i.e. Id from the dynamic content, that will automatically add Appy to each action.
Now click on Save and run the Flow manually, you can see all files are deleted from that SharePoint Folder.
This is an example of Power Automate delete all files in onedrive folder
Read Power Automate export SharePoint list to excel and send an email
Power Automate delete files after a certain time
Here we will see how to delete a file after a certain time from the File System using Power Automate.
In the File System, I have a folder called SharePoint Document, so we will delete the file from the folder after 10days
In Power Automate, select the Manually triggered Flow, then click on the Next step.
Now we will retrieve files from the File system, so select List Files in Folder action, then provide the Folder.
Now we will add a condition that will check the create date of the file, so click on the Next set and select Apply to each action, then provide ‘body’ from the dynamic content. Next click on Add an action, then select Condition Control action. Then in condition add the below condition
- value- utcNow(‘yyyy-MM-dd’)
- operator-greater than
- value- formatDateTime(addDays(item()?[‘LastModified’], 10), ‘yyyy-MM-dd’)
Next, if the condition is true, delete files from the file system folder, so click on Add an action in the IF Yes part, then select Delete File. Then the file Field provides the ID from the dynamic content.
Now click on Save and run the Flow manually, you can see files are deleted from the Folder in File System.
This is an example of Power Automate delete files after a certain time
Read Power Automate delete all items in SharePoint list
Power Automate delete files older than 30 days
Here we will see How to delete files older than 30 days using Power Automate.
I have a folder in the SharePoint library called General, from this folder we will delete all files that are older than 30 days.
Let’s see how to create a flow, that will delete file s that are older than 30 days.
In Power Automate select the Manually triggered FLow, then click on the Next step.
Now we will retrieve the files from the folder, so select Get Files(properties only), then provide the site address, library name and Limit Entries to folder provide the folder path.
Next, we will delete the file that are older than 30 days, so click on the Next step and select Apply to each action. Then provide the value from the dynamic content.
Next click on Add an action and select Condition Control action, then provide
- value – formatDateTime(item()[‘Created’],’yyyy-MM-dd’)
- operator – is less than
- value-addDays(utcNow(),-30,’yyyy-MM-dd’)
Then if the above condition is true we will delete files, so in the If Yes part of the condition, click on Add an action then select Delete file action, then provide the site address and File identifier from the dynamic content.
Now click on Save and run the flow manually Now you can see files are deleted, that are older than 30 days.
This is an example of Power Automate delete files older than 30 days.
Read Power Automate copy files
Power Automate delete files from recycle bin
Here we will see how to delete files from recycle bin using Power Automate.
I have SharePoint Folder called Documents, From which we will delete files permanently, that cannot be restored from recycle bin.
In Power Automate, select the Manually triggered Flow, then click on the Next step.
Now we will get the file from the folder, so click on the Next step and select Get files(properties only), then provide the site address and Library name.
Now we will delete the files permanently with an Http request, so click on the Next step and select Apply to each action, then provide the value. Next click on Add an action, and select Send an Http request to SharePoint action, then provide the Site Address, Method select Delete, In URI provide the API like below format.
_api/web/GetByTitle(‘Your list/library title)/Items(Your item id here)
Now click on Save and run the Flow Manually, and all files are deleted permanently. You can check the recycle bin too.
This is an example of power automate delete files from recycle bin.
Related Power Automate articles:
- Power Automate Array Variable
- Power Automate send email based on form response
- Power automate split string into an array with examples
- Power Automate Rename File
- Power Automate String Functions
- How to Create PDF from Excel using Power Automate
- Conditionally Update SharePoint list items using Power Automate
In this Power Automate tutorial, we learned Power Automate delete file from SharePoint. And also we discuss the below points:
- Power automate delete files in sharepoint folder
- Power automate delete all files in sharepoint library
- Power automate delete files older than
- Power automate sharepoint delete old files
- Power automate delete all files in onedrive folder
- Power automate delete files after a certain time
- Power automate delete files older than 30 days
- power automate delete files from recycle bin
After working for more than 15 years in Microsoft technologies like SharePoint, Office 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 (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Hello!
Your guides are really well written and easy to follow – but I am looking for something that seems to be a step further:
I am trying to build a PowerAutomate workflow that will delete all files, folders and subfolders in a Document Library used for temporary staging.
Because the folders (and subfolders) can vary depending on the items being staged – I haven’t been able to find a solution that will recursively go through each level to clear things out.
We are a government office, so I’m not able to change the Retention policy settings and PowerShell is not really an option either.
Any help is appreciated!
Thank you.
Great article however I don’t want to delete the folders just files in the folders. How can I only delete the files and not the folders? Thanks
Hi Bro
for the Power Automate delete files older than 30 days
when I input “formatDateTime(item()[‘Created’],’yyyy-MM-dd’)” , it shown The expression is invalid. any Idea for this?
Hello, great post!! But, I get an error while trying to delete de file inside the folder:
Action ‘Delete_file’ failed7
El archivo /sites/CRM_Test/opportunity/Mesa Servicios TI 51891 – –54388– – problema al cargar datos_255C20D3B430EB11A813000D3A88A5FB no existe.
clientRequestId: 4bfa1db7-ed16-474a-9717-83665748f8a6
serviceRequestId: af0999a0-2068-3000-333e-5607f0f24e1b
It says that doesn’t exists.
Thanks a lot!
The “older than” simply doesn’t work. Files aren’t deleted. Flow Runs page says it was successful. But I don’t see that it got any files and the files are still in the folder.
Just tried your solution for “Power Automate delete files older than 30 days”. It seems to just delete one file at each run rather than all files that match the condition.