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 Sharepoint Folder
Power Automate
Suggested Answer

Delete Sharepoint Folder

(0) ShareShare
ReportReport
Posted on 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.

 

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    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,

  • mayankgoyal1984 Profile Picture
    8 on at

    @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

  • mayankgoyal1984 Profile Picture
    8 on at

    @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?

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    @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.

     

     

  • Suggested answer
    CU03091917-0 Profile Picture
    26 on at
    This is still not possible in 2024.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard