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 / Delete folders if olde...
Power Automate
Suggested Answer

Delete folders if older than a week

(0) ShareShare
ReportReport
Posted on by
Hi, 
 
I am trying to create a flow to remove all the folders inside another folder (A) if they are older than a week.
 
To do it, after recurrence,
1)I inserted a "Show files in the folder", selecting folder A.
2) For each -> Body/value
3) Conditional -> Last modified is less than addDays(utcNow(),-7)
4)True -> Delete Files -> id
 
However, I am unable to make it work, but I do not know were is my mistake.
 
¿Could someone help me?
 
Thanks
 
Martin
Categories:
I have the same question (0)
  • Suggested answer
    SwatiSTW Profile Picture
    741 Super User 2025 Season 2 on at
    I feel your code if good but please check that -
    1. "Delete file" action does not work for folders; use "Delete folder" instead.
    2. Ensure IsFolder is checked to delete only folders, not files. 
    3. Compare LastModified with addDays(utcNow(), -7) correctly.
    Below is fixed flow with correct expressions and conditions
    1. Trigger: Recurrence (e.g., Daily)
    2. Action: "List folder" (Folder A)
    3. Apply to each: Body/value
        Condition 1: Check if item is a folder
            Expression: item()?['IsFolder']
            If true, proceed.
        Condition 2: Check if older than 7 days
            Expression: item()?['LastModified'] is less than
            Value: addDays(utcNow(), -7, 'yyyy-MM-ddTHH:mm:ssZ')
    4.  If True: "Delete folder" → Id
     
  • CU20031750-1 Profile Picture
    2 on at
    Is it working if the folder A is in OneDrive?
  • Suggested answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at
    Hi
     
     
    I made a tutorial video based on this. Please have a look and comment.
     
  • Suggested answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at
    You need to use Graph API to delete the folder
     
     
    You need premium license to do this. HTTP action step is premium.
     
    If you need further help in this let me know.

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard