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 / OneDrive - Delete File...
Power Automate
Unanswered

OneDrive - Delete Files/Folders older than x days

(0) ShareShare
ReportReport
Posted on by

Hi,

 

As the name implies, I'm looking for a flow that will delete files/folders that are older than 7 days.

 

Any help would be greatly appreciated

Categories:
I have the same question (0)
  • v-zhos-msft Profile Picture
    on at

    Hi @Anonymous ,

    According to your description, you want to delete files/folders that are older than 7 days in OneDrive via MS Flow.

    I have made a test on my side, please take a try with the following workaround:

    The expression of Compose is: addDays(body('Get_file_metadata')?['LastModified'],7,'yyyy-MM-dd'), add 7 days on the last modified date.

    The expression of Condition is: greaterOrEquals(outputs('Compose'),utcNow('yyyy-MM-dd')), judge whether the files are older than 7 days.

    we.png

    2.png

    Best Regards,

    Zhongys

  • Community Power Platform Member Profile Picture
    on at

    @v-zhos-msft 

    I get this error due to being a folder

    {
    "status": 400,
    "message": "Resource : ID is a directory. This API works only on files",
    "source": "api.connectorp.svc.ms"
    }
  • Community Power Platform Member Profile Picture
    on at

    Hi,

     

    I still want to build this flow, any help please?

  • JHufford Profile Picture
    2 on at

    Did you ever get this working? I'm attempting to do the same thing

     

    When I run the flow I get the error:

    Unable to process template language expressions for action 'Condition' at line '1' and column '2225': 'The template language function 'greaterOrEquals' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'Boolean'.'.

  • pawelrudner Profile Picture
    2 on at

    I find it still can delete files only, not folders. Anyone resolved this issue?

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