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 / How to delete Files in...
Power Automate
Answered

How to delete Files in SharePoint Document Library using Power Automate?

(0) ShareShare
ReportReport
Posted on by

Hello Community Members,
Any help would be appreciated for my issue!

I have a SharePoint document library with Folders, Inside the folder, files are present as shown below:

Lidia_0-1711628168515.png

I have created a flow that will delete files older than 3 months. Files are getting deleted, but the flow is failing. Why is this happening?

Lidia_1-1711628297062.png

 

Input:

Lidia_2-1711628829731.png

 

Lidia_3-1711628847623.png

Thanks in Advance
Regards!
Lidia

 

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

    Hi @Lidia ,

     

    Judging from the screenshots, some of the "Delete file" runs failed. Please click the right arrow to see which "Delete file" failed and check the error message.

    vmengmlimsft_0-1711629919238.png

     

     

     

    Best regards,

    Rimmon

  • LH-28081619-0 Profile Picture
    on at

    Thank you for the reply!

    Lidia_0-1711630540216.png

    This is the error that i was getting.. It is a folder .. not deleting the folders
    I wanted to delete all the files and folders which are older than 3 months. But it is only deleting the files.

  • v-mengmli-msft Profile Picture
    on at

    Hi @Lidia ,

     

    You can add a condition to check if the file is folder before deleting it.

    vmengmlimsft_0-1711630899447.png

     

     

    Best regards,

    Rimmon

     

  • LH-28081619-0 Profile Picture
    on at

    But you have given here IsFolder is equal to false, then it won't delete the folder, right. I wanted to delete the folders as well

     

  • LH-28081619-0 Profile Picture
    on at

    Lidia_0-1711632272460.png

     

  • Verified answer
    v-mengmli-msft Profile Picture
    on at

    Hi @Lidia ,

     

    Sorry for that. I didn't notice that.

    Please try this.

    vmengmlimsft_0-1711632723133.png

     

     

    Best regards,

    Rimmon

  • v-mengmli-msft Profile Picture
    on at

    Hi @Lidia ,

     

    One more thing to add, you don't even need "Delete file", "Delete item" can delete all files and folders directly.

     

    Best regards,

    Rimmon

  • LH-28081619-0 Profile Picture
    on at

    Do I need to add the condition for both things that you have shown in the screenshot?

  • LH-28081619-0 Profile Picture
    on at

    Lidia_0-1711644179533.png

    It has failed.. although I followed the same steps, It is showing as Item ID 22 is not found , but the item is there in the folder 

    Lidia_2-1711644319677.png

    But for some Id- Which are folders, it is getting deleted

    Lidia_3-1711644521431.png

     

  • v-mengmli-msft Profile Picture
    on at

    Hi @Lidia ,

     

    The error shows ItemId 23 not found. From your library, there is no file's Id is 23, the file may be deleted by previous flow run.

     

    There should be some actions in the flow that run on the original data. I recommend that you trigger a new process and not run it from one of the previous processes.

    vmengmlimsft_0-1711708929595.png

     

     

    Best regards,

    Rimmon

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 375 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 269 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 127 Most Valuable Professional

Last 30 days Overall leaderboard