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 Platform Community / Forums / Power Automate / Delete all subfolders ...
Power Automate
Unanswered

Delete all subfolders and files within document set while preserving document set

(0) ShareShare
ReportReport
Posted on by 8

Hello, I am searching for a solution for the following scenario. There is a SPO document library with one standard document set. There are about 20 or so document sets in the library. Within each doc set there can be any variety of subfolders or files, files within folders, etc. All that I am trying to do is delete all of the document set contents with a flow without deleting the entire document set. The idea is that the document set will continue to be used and I want to maintain the ID. I've tried the built-in delete file or delete item actions but they are not working for both files and folders. Delete file doesn't recognize folders and will throw an error saying that the file wasn't found and the delete item can't seem to look through subfolders to delete those files and also throws an error. I've seen people suggest the HTTP request action but it looks like that would delete the entire document set which I would like to avoid. 

 

Any suggestions are greatly appreciated. Thank you

Categories:
  • Unknown geen idee Profile Picture
    1,757 on at

    Dear S,

    I am not sure I see your problem. 

    With a 'List items' in sharepoint you can get all the items and with the field 'IsFolder' you can view files from folders.

    If you have any specific criteria to determine what folder/file is something you want to keep you can use a Filter Array to figure out what to delete or not.

    You may need to loop through several of the underlying folders with another 'List items' to delete all the lower elements.

     

    Hope this helps,

    Happy flowing,

    Koen

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard