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 / Deleting files from mu...
Power Automate
Answered

Deleting files from multiple document libraries

(0) ShareShare
ReportReport
Posted on by 12

Basically what I want to do is to delete all the files from 20 libraries.  It's basically a cleanup flow.  I don't want to delete the libraries themselves but I want to delete the files / folders inside each library.

I can do this by manually doing a get items per library and then using the apply to each and then delete item action card and it works but what I want to do is to have a simpler flow that would read a list that has each document library name in it.  Do a get items based on that list.  Then return those library names to use in the next get items that would get the items in each library and then from there use the delete item action card to delete all the files.

It seems simple enough in my head but when I attempt to do the lookup of the document library names in the list that works fine and I return the output of all 20 libraries.  Then when I take those libraries and do a get items for each library I can do that and it works, BUT when I do the delete action card it doesn't allow me to select any of the output from the 2nd get items action card.  It only show's the first.  I'm new to flow so I'm sure I'm just doing something wrong but for the life of me I can't see what it is and why flow isn't allowing me to use any of the output listed from the 2nd get items to delete them.

Annotation 2019-03-08 183350.png

 

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

    Hi @Itprofessional ,

     

    Do you mean that the Departments list contains the Library name that needs to be emptied of files?

    Then, according to these names, all the files in the current Library that need to be deleted.

     

    • All you have to do is add an Apply to each outside of “Delete item“ action and use the value of Get items 2 as the traversal.
    • And use "items('Apply_to_each_2')['ID']" to get item ID of the current file or folder. If Flow is executed, an error may occur, which is normal.

     

    Delete item action does not discriminate between files or folders, if the folder is deleted first, the files inside will also be deleted. When the ID of the file inside the folder is traversed, "Item not found" is displayed.

    You could ignore this error and check directly if the files have been deleted.

     

    Image reference:

    5.PNG

    Please take a try.

     

    Best Regards,

  • Itprofessional Profile Picture
    12 on at

    That worked! Thanks!

  • David_RO Profile Picture
    17 on at


    Delete item action does not discriminate between files or folders, if the folder is deleted first, the files inside will also be deleted. When the ID of the file inside the folder is traversed, "Item not found" is displayed.

    You could ignore this error and check directly if the files have been deleted.

     


    Hello,

     

    There is no other way than ignoring the "Item not found" error ? It's not a very suitable option for me.

     

    Thanks,

    David

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

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard