cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Delete Files in SharePoint Folder based on LastModified - X Days

Hello,

 

I am building a flow to delete files on a SharePoint folder based on the date Last Modified - X Days.

I used the following approach as a guideline: https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Delete-files-older-than-X-days-fro...

 

alberto1_1-1630089687704.png

 

However it seems I am getting a wrong output in the LastModified field as per screenshots: "0001-01-01T00:00:00"

 

 

alberto1_0-1630089638052.png

 

 

Am I using the correct field for this purpose?

 

Can anyone assist?  

 

Thank you!

4 REPLIES 4
kierian
Community Support
Community Support
Anonymous
Not applicable

So I replicated that flow, but it doesn't seem to be doing anything:

 

alberto1_0-1630096354015.png

alberto1_1-1630096461018.png

 

Were you able to replicate it?
Any ideas?

 

 

Hi @Anonymous 

Has your problem been solved?

If you want to delete a file based on it's modified date , you can refer to the following screenshots.

I have a folder like this:

vLilyWmsft_0-1630290943528.png

Flow in details:

vLilyWmsft_1-1630290943531.png

vLilyWmsft_2-1630290943534.png

Expression: formatDateTime(items('Apply_to_each')?['Modified'],'yyyy-MM-dd')

Expression: addDays(utcNow(),-7,'yyyy-MM-dd')

vLilyWmsft_3-1630290943538.png

 

After flow runs, the files will be deleted.

vLilyWmsft_4-1630290987405.png

Hope the content above may help you.

Best Regards

If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

It doesn't seem to work for me. I'm getting that the flow is running successfully, but nothing is getting deleted; I still have files from January...

 

Not sure what is going on...

 

alberto1_0-1630589392338.pngalberto1_1-1630589465749.png

 

formatDateTime(items('Apply_to_each')?['Modified'],'yyyy-MM-dd')
addDays(utcNow(),-7,'yyyy-MM-dd')

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,560)