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 / Auto Delete Files afte...
Power Automate
Unanswered

Auto Delete Files after X amount od days

(0) ShareShare
ReportReport
Posted on by 14

Hey Guys,

 

I copied this flow (https://powerusers.microsoft.com/t5/Using-Flows/Automatically-delete-files-in-Document-Library-after-X-days/td-p/70009)  and had it working for a document library.

 

However I am trying to recreate this flow again on a different site and it runs sucessfully but is not deleting anything.

 

Ultimately I want to to delete any files older than 2 years in age (Date Created/Added/Uploaded to Site)

 

I am just trying to get it to delete after 1 day to verify it works before I change it to 730 days

 

I am using this:

@equals(formatDateTime(item()?['Created'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), -1), 'MM/dd/yyyy'))

 

Here is how my flow is layed out currently:

https://imgur.com/a/17gFUT3

 

https://imgur.com/a/46ZZaAU

 

Does it matter if the folder CGI which I am looking to delete the files in, is inside another folder?

 

company.sharepoint.com/shared documents/folder1/CGI

 

Any ideas why its not deleting the files in the CGI folder? They were all created/uploaded over a week ago.

 

Like I mentioned I have it working no issues on my other site but this one it doesn't seem to work.

 Thanks.

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @ufc205:

     

    Take a look at this solution as I believe it is very close to what you need.

     

    If this answers your question, please mark your post as Solved.

     

    Scott

  • ufc205 Profile Picture
    14 on at

    Hey Scott, no I've seen that link but that is for files on an Azure FS it looks like but in any case like I mentioned I have the same setup working on another site.

     

    But for some reason this site its not working for and the flow runs sucessfully but doesnt delete anything.

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @ufc205:

     

    Sorry - I missed that part of your post.....

     

    When you look at the for each loop for a run of the Flow, does it give any indication of why the condition was not met?  Is it looping the correct number of times?

  • ufc205 Profile Picture
    14 on at

    Not sure what you're asking you left out a word 🙂

     

    But does this help give any indication? This is from my run history for that flow:

     

    https://imgur.com/a/tWKBTiy

     

     

  • ufc205 Profile Picture
    14 on at

    bump, any one else have any ideas?

     

    I am a site owner on both sites too.

     

    Will this method not work if the folder im trying to delete the files from is not at top level of document library???

  • ufc205 Profile Picture
    14 on at

    Smiley Sad

  • ufc205 Profile Picture
    14 on at

    Does MS offer support on flows at all?

     

    I really need to get this figured out but even if I had to pay for support thats ok.

  • ufc205 Profile Picture
    14 on at

    Would it matter if its the top level site.

     

    The document library I am trying to run this on is on

     

    https://mycompany.sharepoint.com/Shared Documents/

     

    Which is just the main Document Library on the site.

     

    The site my flow works on with no issues is:

     

    https://mycompany.sharepoint.com/sites/Testsite

     

    And then a document library under here.

     

    The issue is the flow on the top level site shows that it runs sucessfully but its not actually deleting any files.

     

    On the Testsite it works perfectly.

  • GabrielStJohn Profile Picture
    Microsoft Employee on at

    Hello, @ScottShearer!

    Thank you for posting a reply to a topic on the Microsoft Flow Community! It appears that the users who you have been engaging in this thread with are now awaiting your reply! Please follow-up on this thread ASAP.

     

    Thank You!

    -Gabriel

    Microsoft Flow Community Manager

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 573

#2
Valantis Profile Picture

Valantis 407

#3
11manish Profile Picture

11manish 387

Last 30 days Overall leaderboard