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

Community site session details

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

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:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at
    Re: Delete files older than 3 years

    @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
    Re: Delete files older than 3 years

    I dont understand how to write step 3 and 4.

  • Godmaster Profile Picture
    38 on at
    Re: Delete files older than 3 years

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

  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Delete files older than 3 years

    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
    Re: Delete files older than 3 years

    Thanks you so much v-bacao-msft

  • Godmaster Profile Picture
    38 on at
    Re: Delete files older than 3 years

    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
    Re: Delete files older than 3 years

    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
    Re: Delete files older than 3 years

    @Godmaster 

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

     

  • Godmaster Profile Picture
    38 on at
    Re: Delete files older than 3 years

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

  • MichaelVreuls Profile Picture
    on at
    Re: Delete files older than 3 years

    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

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 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard