Skip to main content
Best answer

How to automate file deletion in SharePoint for files older than three days


Hi,

I’ve been trying to setup an automation that locates and deletes files in a Sharepoint document library (folder) older than three days and deletes them.  Thought this was going to be a simple automation to create but it has proved pretty difficult.  I understand creating a filter for the older than three days criteria but cannot figure out how to delete them.  Anyone have any pointers?  It seems like I may have to go the API route...just not sure.  Thank you!

Best answer by SamBBest answer by SamB

Hi and welcome to the Community, ​@cbs01! 🎉

I just checked and there aren’t any “Delete File” actions available for the Microsoft Sharepoint app. We do have a feature request for a “Delete File” action to be added though, so I went ahead and added your vote for it. We can’t make any guarantees on if/when it will be added, but you’ll definitely get and email notification from us if it is.

In terms of a workaround I think you’re right and you’d need to look at going down the API route. The Microsoft Sharepoint app has an API Request action you could potentially use delete the file. They’ve got an example showing it’s possible to make a request to their API that would delete a file here: Working with files by using REST

ce0053d512449c505f5ccf9b5e1818b5.png

It’s more advanced than Sharepoint’s other actions but we’ve got a Set up an API request action that you might find useful. 

If you do give that a try and run into any trouble just let us know—always happy to lend a hand! 🙂

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7592 replies
  • Answer
  • January 23, 2025

Hi and welcome to the Community, ​@cbs01! 🎉

I just checked and there aren’t any “Delete File” actions available for the Microsoft Sharepoint app. We do have a feature request for a “Delete File” action to be added though, so I went ahead and added your vote for it. We can’t make any guarantees on if/when it will be added, but you’ll definitely get and email notification from us if it is.

In terms of a workaround I think you’re right and you’d need to look at going down the API route. The Microsoft Sharepoint app has an API Request action you could potentially use delete the file. They’ve got an example showing it’s possible to make a request to their API that would delete a file here: Working with files by using REST

ce0053d512449c505f5ccf9b5e1818b5.png

It’s more advanced than Sharepoint’s other actions but we’ve got a Set up an API request action that you might find useful. 

If you do give that a try and run into any trouble just let us know—always happy to lend a hand! 🙂


  • Author
  • Beginner
  • 1 reply
  • February 24, 2025

Thank you for this.  I finally figured out a way to do this in Power Automate so all is well now.  :)


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7592 replies
  • February 25, 2025

You’re welcome, ​@cbs01 🤗 Glad to hear you found an alternative solution! If there’s anything else we can help with, feel free to reach back out. Until then, happy Zapping! ⚡