I have a document library named documents and a folder in it called PDFs. In the PDFs folder, I have a bunch of PDFs. I want to be able to create a flow that will automatically delete the PDF files after 30-days. I have tried creating a flow but am unsuccessful. I am not sure how to limit it to the PDFs folder. Also, i can only get it to delete a single file that i choose and not multiple files in the folder.
Thanks for the reply. I actually did a test flow without the file age condition just to see if it would actually delete the files in the document library. Here is what the result was. I created a document library with this structure:
Document Library/Test Folder 1/Test Folder 2
This work fine and all the files delete as expected. Problem is, I have another document library name "Documents" and there are subfolders in there as well. When I use the same flow that worked on the other document library and change the library location, none of the files delete. I have full control permissions on both dicument libraries. The strange thing is the filter array has an output, but it doesnt show the files
that are in the document library (2 PDFs).
Hi @Anonymous,
Could you please share a screenshot of your flow's configuration?
Do you want to delete the files in your SharePoint library folder when they are 30 days old?
I have made a test on my side and please take a try with the following workaround:
Within "If/yes" branch of Condition, add a "Condition 2", click "Edit in advanced mode", type the following formula:
@equals(formatDateTime(item()?['Created'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), -30), 'MM/dd/yyyy'))
Within "If/yes" branch of Condition 2, add a "Delete file" action, specify Site Address and the File Identifier field set to Identifier dynamic content of the "Get files (properties only)" action.
Image reference:
The flow works successfully as below:
Best regards,
Kris
Tomac
986
Moderator
stampcoin
699
Super User 2025 Season 2
Riyaz_riz11
577
Super User 2025 Season 2