web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Need to automate delet...
Power Automate
Unanswered

Need to automate deleting files in sharepoint older than 7 days

(0) ShareShare
ReportReport
Posted on by 38

Hi there,

 

I am currently setting up flows for my work. I have files going in on a daily basis and once the file is a few days old it is no longer relevant so planning to upkeep 7 days worth. 

I have searched for solutions, followed guides, and I can't seem to get it to work. I have been doing testing on it so there is files that are 3 and 4 days old, so setting the parameters to delete files older than 2 days. 

 

The Test runs however nothing gets deleted.

 

any help would be greatly appreciated. 

 

christophermc_0-1689079533963.png

christophermc_1-1689079589555.png

 

 

Categories:
I have the same question (0)
  • annetoal Profile Picture
    1,934 Moderator on at

    Instead of an ODATA filter, try this instead:

    Use the Filter action to filter.

    annetoal_0-1689081081661.png

    The Created label was picked from the dynamic data picker.

    The time I used was utcNow(). You may want to customize that to your own needs.

    addDays(utcNow(),-7)

    If this helped, please mark it as a Solution and give it a thumbs up.

    Anne

     

  • christophermc Profile Picture
    38 on at

    Hi Anne,

    Where would I place this? would it be between Get files and Apply to each or before Get Files? 

    thanks

  • annetoal Profile Picture
    1,934 Moderator on at

    Has to be after Get files (properties only)

     

     

  • christophermc Profile Picture
    38 on at

    unfortunately that doesn't seem to of made a difference.  

    christophermc_0-1689081629455.png

     

  • annetoal Profile Picture
    1,934 Moderator on at

    Show your Flow outputs from a run. Does the filter produce the array of files you want to delete?

  • trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at

    Hi @christophermc ,

     

    Please try filter array - the results look good in my test; modify as needed.  Always glad to help!  Tom

     

    trice602_0-1689081823986.png

     

  • christophermc Profile Picture
    38 on at

    christophermc_0-1689081916225.png

    this is the result of running it

  • annetoal Profile Picture
    1,934 Moderator on at

    Looks like the problem is you don't have any files in your library that are more than 7 days old. You may want to adjust your addDays parameter to something else, or put some older files in your test group.

  • christophermc Profile Picture
    38 on at

    That is why currently it is set to -3 instead of -7 so I can make sure it works. then once it all works I will manually delete the files and let it do its thing daily

  • annetoal Profile Picture
    1,934 Moderator on at

    What are the Created dates in the Get files (properties only) outputs for the files you're testing?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard