Delete Files Older than 3 Years from SharePoint Document Library Using Power Automate
This Power Automate solution is designed for employees or clients who are using the SharePoint document library to store files and later want to delete unnecessary files/folders older than 3 years. So, we have created a Manual trigger flow in Power Automate to delete SharePoint document library files and folders older than 3 years at once and save time.
We will create a SharePoint Online document Library [Course Documents] with these columns below: [Also, we will upload some files, folders, files inside folders, subfolders, etc. into it].
- Name - Default column for Library
- Test Date - Date and Time Column
- ID - Default Column
- Modified - The Default column represents the modified date and time
- Modified By - The Default column represents who is modified currently
Make sure you have created the SharePoint document library as described, and then only go for installation and implementation of the solution.
What does the flow do?
Once the flow is triggered manually, it will initiate and delete the files present in the SharePoint document library and in folders and subfolders older than 3 years.
I have added one more step to delete folders, which will satisfy the condition and delete the folders.
For more than 5000 items/files, we need to turn on the pagination in the Get items flow action, which will fetch 100000 items from SharePoint.
After that, we will run the flow to delete files/ folders older than 3 years from the SharePoint document library.
Let's Download the Solution and try it out!!