web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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

I have the same question (0)
  • Unknown geen idee Profile Picture
    1,757 on at
    Re: Delete all subfolders and files within document set while preserving document set

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 797 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 425 Moderator

#3
developerAJ Profile Picture

developerAJ 319

Last 30 days Overall leaderboard