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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Delete files older tha...
Power Automate
Answered

Delete files older than 3 years

(1) ShareShare
ReportReport
Posted on by 38

Hello,

 

I would like to create a flow to delete files older than 3 years ( date of creation ) in a sharepoint librairy.

I watched  some exemples in this site but advanced condition are not working anymore ( option not visible )

Need help thanks you !

Categories:
  • efialttes Profile Picture
    14,756 on at

    @Godmaster 

    Are you using a "Condition" action block to evaluate if a File is olderenough to be deleted?

    If so, it seems "edit in advanced mode" option is not available anymore since some improvements in the UI were implemented for this action block.

    Please also note this "edit in advanced mode" is still available on "Filter array" action block. So if you prefer yo can implement a filter based approach instead

    Step#1 Manual trigger or REcurrence trigger

    Step#2 Sharepoint "Get items" from target SP Library

    Step#3 "Filter array" action block to skip the files not old enough

    Step#3 "Apply to each" using the output of "Filter array" as its input

    Step#3.1 Delete file, using the ID from current item

     

    So in step 3, flow will iterate all through the files old enough to be deleted

    Hope this helps

  • Godmaster Profile Picture
    38 on at

    I dont understand how to write step 3 and 4.

  • Godmaster Profile Picture
    38 on at

    Capture.PNG
    how can we write this since the advanced condition is not available anymore ?

  • Verified answer
    v-bacao-msft Profile Picture
    Microsoft Employee on at

    Hi @Godmaster ,

     

    You could configure the following Expression in Condition.

    At present, Flow can't get the number of days in the past three years. So I use a year with 365 days to calculate.

     

    • Use formatDateTime() function to format Created into ‘yyyy-MM-dd’ and then calculate the date three years ago.
    • If the former is less than the latter, then the current file is deleted.

    Expression reference:

    formatDateTime(item()['Created'],'yyyy-MM-dd')
    addDays(utcNow(),-1095,'yyyy-MM-dd')

    Image reference:

    19.PNG

    Hope it helps.

     

    Best Regards,

  • Godmaster Profile Picture
    38 on at

    Thanks you so much v-bacao-msft

  • Godmaster Profile Picture
    38 on at

    I spoke too fast, there is a little problem lol
    I watch in the history of the flow and i see that there is a limit of 100 entries for the condition

    How can i can cross this limit of 100 items ?

    Capture.PNG

  • Godmaster Profile Picture
    38 on at

    I have found the solution to cross more than 100 entries.
    In the"get property" i put a value of 5000 elements.

    Capture.PNG

  • efialttes Profile Picture
    14,756 on at

    @Godmaster 

    Good news! Please do not forget to Accept the solution from @v-bacao-msft !

     

  • Godmaster Profile Picture
    38 on at

    Do you know how to go beyond 5000 items ? My librairy has more than 10000 items
    Its really disappointing...

  • MichaelVreuls Profile Picture
    on at

    Thanks
    It works as long as "Get Files (Properties only)" is preceded by "List Files in Folder".
    (took me a while to find that out 😉

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 330

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 123

Last 30 days Overall leaderboard