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 : 9H3PEUiYRkr7EtFXCjL/JG
Power Automate - Building Flows
Suggested answer

Delete Sharepoint Folder

Like (0) ShareShare
ReportReport
Posted on 25 Sep 2020 04:14:36 by 8

Hi, I have a Sharepoint folder in a path on Sharepoint like - Shared Documents/My Folder/Output/....

This output folder has lots of folder in it with files in each folder. I have to delete all folders in Output folder. Please suggest.

 

  • Suggested answer
    CU03091917-0 Profile Picture
    26 on 03 Sep 2024 at 20:28:10
    Delete Sharepoint Folder
    This is still not possible in 2024.
  • v-bacao-msft Profile Picture
    on 29 Sep 2020 at 06:03:34
    Re: Delete Sharepoint Folder

     

    @mayankgoyal1984 ,

     

    The method I provided will ignore the subfolders when deleting the folder, because when deleting the parent folder, all the contents inside will be clear, including subfolders. Every folder and file will have an item ID, and we rely on it for deletion.

     

     

  • mayankgoyal1984 Profile Picture
    8 on 28 Sep 2020 at 08:18:03
    Re: Delete Sharepoint Folder

    @v-bacao-msft - Only thing I was initially in doubt was that when deleting child folder, I am using delete item where I am providing List name as Documents and Id as folder ID which is a number, I hope in Sharepoint each folder has this unique ID number as in delete item I dont have option to provide any full path, hence it will delete item in Documents library with that ID number. Please confirm if you know about this?

  • mayankgoyal1984 Profile Picture
    8 on 28 Sep 2020 at 08:15:24
    Re: Delete Sharepoint Folder

    @v-bacao-msft - Thanks a lot for your response. When getting child folder in parent output folder, I am providing the right path of parent output folder in Limit Entries to folder field. With this I believe the files entire scope of delete will be limited to this parent output folder.

    Once I get all folder (child folder) of parent output folder - I am looping on each of it and deleting files from each child folder to avoid error (till folder is not empty it cant be deleted). Once all files from child folder are deleted I am deleting child folder. So on a high level flow looks like - 

     

    Get all child folders in Parent folder

    Loop on child folders

          Get Files in Child folder

          Loop on files in child folder

                Delete file from child folder

          Next

          Delete Child Folder

    Next

  • v-bacao-msft Profile Picture
    on 28 Sep 2020 at 07:01:54
    Re: Delete Sharepoint Folder

     

    Hi @mayankgoyal1984 ,

     

    I think @yashag2255 's suggestion is correct. Please pay attention to whether these folders contain important files to avoid accidental deletion.

     

    In addition, you could refer to the screenshot below to configure Flow:

    75.PNG

    Errors similar to "item not found" may appear when Flow is running. You can ignore these errors. Because the Get files action will get the subfolder and the files in it, when Delete item deletes the subfolder, it will also delete the files in the subfolder, so when traversing to the files in the subfolder, an error will be reported. This is in line with expectations.

     

    Hope this helps.

     

    Best Regards,

  • yashag2255 Profile Picture
    24,656 Super User 2024 Season 1 on 25 Sep 2020 at 05:05:34
    Re: Delete Sharepoint Folder

    Hi @mayankgoyal1984 

     

    Note that if there is a retention policy activated in SharePoint, Folders with data cannot be directly moved or deleted. You will have to use the list folder action and then check if the file is a folder or a file and if it is a file delete it and if not again list contents of that folder and so on. 

     

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete