Power Automate delete file from SharePoint

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.

power automate delete all files in sharepoint folder
power automate delete all files in SharePoint 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.

How power automate delete all files in sharepoint folder
How power automate delete all files in SharePoint folder

Now we will retrieve files from the SharePoint library, so select Get Files (Properties only) action. Then provide the site address and Library name.

How Microsoft Flow delete all files in sharepoint folder
How Microsoft Flow delete all files in SharePoint folder

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/.

 Microsoft Flow delete files in sharepoint folder
Microsoft Flow delete files in SharePoint folder

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}']
MS Flow delete files in sharepoint folder
MS Flow delete files in sharepoint folder

Now click on Save and run the flow Manually, you can see all files are deleted from the SharePoint Folder.

How MS Flow delete all files in sharepoint folder
How MS Flow delete all files in 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.

Microsoft FLow delete all files in sharepoint library
Microsoft FLow delete all files in SharePoint library

In Power Automate, select the Manually triggered Flow, then click on the Next step.

power automate delete all files in sharepoint library
power automate delete all files in SharePoint library

To retrieve all files from the SharePoint folder, select Get Files(Properties only), then provide the site address and Library name.

How power automate delete all files in sharepoint library
How power automate delete all files in SharePoint library

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.

How Microsoft Flow delete all files in sharepoint library
How Microsoft Flow delete all files in SharePoint library

Now click on Save and run the flow manually, you can see files get deleted from the SharePoint library.

How MS Flow delete all files in sharepoint library
How does MS Flow delete all files in 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.

power automate delete files older than
power automate delete files older than

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.

power automate delete files older than 7 days
power automate delete files older than 7 days

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'))'
How Microsoft Flow delete files older than
How does Microsoft Flow delete files older than

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.

Microsoft Flow delete files older than
Microsoft Flow delete files older than

Now click on Save and run the Flow manually, you can see the files that are older than 7 days.

MS Flow delete files older than
MS Flow delete files older than

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.

power automate sharepoint delete old files
power automate SharePoint delete old files

In the Power Automate, select the Manually triggered Flow, then click on the Next step.

How power automate sharepoint delete old files
How power automate SharePoint delete old files

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'))'
Microsoft Flow sharepoint delete old files
Microsoft Flow sharepoint delete old files

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.

How Microsoft Flow sharepoint delete old files
How Microsoft Flow SharePoint delete old files

Now click on Save and run the Flow manually, and you can see the 20-day old files are deleted from SharePoint Folder.

 MS Flow sharepoint delete old files
MS Flow SharePoint delete old files

This is an example of Power Automate SharePoint delete old files

Read Power Automate Compose

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.

power automate delete all files in onedrive folder
power automate delete all files in 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.

How power automate delete all files in onedrive folder
How power automate delete all files in onedrive folder

Now we will retrieve all files from that folder, so select List Files in Folder action, then provide the Folder path.

Microsoft Flow delete all files in onedrive folder
Microsoft Flow delete all files in onedrive folder

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.

MS Flow delete all files in onedrive folder
MS Flow delete all files in OneDrive folder

Now click on Save and run the Flow manually, you can see all files are deleted from that SharePoint Folder.

How MS Flow delete all files in onedrive folder
How MS Flow delete all files in OneDrive 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

power automate delete files after a certain time
power automate delete files after a certain time

In Power Automate, select the Manually triggered Flow, then click on the Next step.

Microsoft Flow delete files after a certain time
Microsoft Flow delete files after a certain time

Now we will retrieve files from the File system, so select List Files in Folder action, then provide the Folder.

How power automate delete files after a certain time
How power automate delete files after a certain time

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.

How Microsoft Flow delete files after a certain time
How Microsoft Flow delete files after a certain time

Now click on Save and run the Flow manually, you can see files are deleted from the Folder in File System.

How MS Flow delete files after a certain time
How MS Flow delete files after a certain time

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.

power automate delete files older than 30 days
power automate delete files 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.

Microsoft Flow delete files older than 30 days
Microsoft Flow delete files older than 30 days

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.

Microsoft Flow delete files older than 30 days
Microsoft Flow delete files older than 30 days

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.

How Microsoft Flow delete files older than 30 days 1
How Microsoft Flow delete files older than 30 days

Now click on Save and run the flow manually Now you can see files are deleted, that are older than 30 days.

MS Flow delete files older than 30 days
MS Flow delete files 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.

power automate delete files from recycle bin
power automate delete files from recycle bin

In Power Automate, select the Manually triggered Flow, then click on the Next step.

power automate delete files from recycle bin
power automate delete files from recycle bin

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.

How power automate delete files from recycle bin
How power automate delete files from recycle bin

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)

How Microsoft Flow delete files from recycle bin
How Microsoft Flow delete files from recycle bin

Now click on Save and run the Flow Manually, and all files are deleted permanently. You can check the recycle bin too.

How MS Flow delete files from recycle bin
How MS Flow delete files from recycle bin

This is an example of power automate delete files from recycle bin.

Related Power Automate articles:

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
>