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 Automate
Answered

delete files

(1) ShareShare
ReportReport
Posted on by 63

I have this flow

ddelias_0-1720010848929.png

 

which deletes files older than 15 days, it worked fine until the month changed to July and it does not delete the files, is it possible that this is the reason?
It is also true that I have more than 20 files in the directory to delete, can it be for this reason?

any idea?

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,968 Super User 2026 Season 2 on at

    Hi @ddelias 

     

    Thank you for sharing the flow picture, but you are asking us to debug your code when you didn't share the actual expressions.

     

    Go into a Run, look at the inputs and outputs of the actions. My guess is your Expression is probably wrong. 

     

    But we need to see the actual data that is flowing through one of the flows that you think should have deleted data.

     

    Also, have you looked at the last modified date of the files???? Are there any files to actually delete?

     

    So when you say something doesn't work, try to build a clear visual explanation

    here are my files, see the last modified date is over 15 days

    here are my expressions

    here is the expression in a run, it shows the date that should have deleted the file etc

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Michael E. Gernaey Profile Picture
    53,968 Super User 2026 Season 2 on at

    Hi @ddelias 

     

    Thank you for sharing the flow picture, but you are asking us to debug your code when you didn't share the actual expressions.

     

    Go into a Run, look at the inputs and outputs of the actions. My guess is your Expression is probably wrong. 

     

    But we need to see the actual data that is flowing through one of the flows that you think should have deleted data.

     

    Also, have you looked at the last modified date of the files???? Are there any files to actually delete?

     

    So when you say something doesn't work, try to build a clear visual explanation

    here are my files, see the last modified date is over 15 days

    here are my expressions

    here is the expression in a run, it shows the date that should have deleted the file etc

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • ddelias Profile Picture
    63 on at

    if sorry, just say things as if they were known
    today is july 3rd and I would have to delete the files of june 16th and they are still in the directory as shown in the image.

     

    ddelias_1-1720027287440.png

     

    I have tried these two expressions in the condition

    formatDateTime(addDays(utcNow(), -15), 'yyyy-MM-ddTHH:mm:ssZ')

    addDays(utcNow(), -15)

    but it only works for the current month

     

    ddelias_0-1720027219145.png

    ddelias_2-1720027382673.pngddelias_3-1720027404001.png

    regards

  • Michael E. Gernaey Profile Picture
    53,968 Super User 2026 Season 2 on at

    hi @ddelias 

     

    Go into the flow, on the details page, open one of the runs (like today) that you think would have deleted files.

    Go to the apply to each

    Step through it for each iteration

    look directly at the Condition

    What value was in the left and what value is in the right

     

    That will tell us if the code thought it should have deleted or not (i'll say the engine).

    also, in that list of files you shared, is that the created date or modified date?

     

  • ddelias Profile Picture
    63 on at

    good morning
    inside the directory where the files to be deleted are, there are 92, it only checks 20 (this is what appears in list files in folder) and leaves the 15 most recent ones, I thought this 15 was because I put in the expression this: addDays(utcNow(),-15,'yyyy-MM-dd') but I modified the 15 for a 25 and it does the same thing

     

    ddelias_0-1720083777848.png

     


    in the apply to each only checks 20 of the 92 and all of them in false (that's why it doesn't delete any) because they are not older than 15 days as you can see in the image.

    ddelias_1-1720083935696.png

     

     

     

  • ddelias Profile Picture
    63 on at

    another thing I have noticed is that it checks until the word June appears.

     

    ddelias_0-1720084137552.png

     

     

  • Michael E. Gernaey Profile Picture
    53,968 Super User 2026 Season 2 on at

    Hi @ddelias 

     

    Sorry but I am a little confused now. Do you have a development environment where it is acting the same? Or is this just in production and nowhere else to test? In your Compose, which I am guessing its the Last Modified Date or the File in the Loop? That clearly shows the file is NOT over 15 days old, so it wouldn't be deleted. 

     

    You shared a picture of files from June before, now this list shows files from this week. You have to narrow it down and not try to solve it for all files.

     

    Actions to Take please

    1. I see that your flow has 20 iterations in the Apply to each. Click through every single one of them and look at the Compose output. See if ANY of the Last Modified dates are older than 15 days. If you find that none of them are, then it makes sense that its not doing anything.

     

    If you still believe it SHOULD be doing something then do the following.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

    1. Pick a file that is older than 15 days and make sure it's the last modified time/date not created

    2. Grab the name so you know what it is

    3. If you are able, because the is DEV, then ad another compose where the first one is, and put the File Name in it.

    4. Run the Flow

     

    Once again, review the Run and step through each of the Iterations of Apply to Each

    Review the Name of the File to verify if its the one you are debugging

    If so then look at the compose of the last modified date time

     

    If its not showing the date that should be deleted, then we have to dig further.

     

    Right now, the most important is, can you reproduce it with a single file that SHOULD be deleted and isn't and not look at lists, thats not going to help. Narrow the debugging field a ton.

     

  • ddelias Profile Picture
    63 on at

    I will try to explain , but for me it is difficult because English is not my mother tongue and I am not an expert in power automate.
    if I put that it deletes the files of less than 5 days old, it does it because it does not exceed the number of 20, but as what I pretend is that it deletes the files of 15 days and there are 92 files, then it does not do it, but if I do not exceed the 20 files if it deletes them, I do not know if I have explained well
    the problem that I see is that there are more than 20 files and it is not able to check all the files.
    What do you think?

  • Michael E. Gernaey Profile Picture
    53,968 Super User 2026 Season 2 on at

    hi @ddelias 

     

    Are all the files in the Robot Folder or are some in subfolders?

     

  • ddelias Profile Picture
    63 on at

    all are in Robot folder

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 258 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 198 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 136 Super User 2026 Season 2

Last 30 days Overall leaderboard