How to delete folder that is not empty using the cli?

I tried to delete folder and getting message ‘…folder not empty’. How can I empty contents of folder so I can delete folder? Or is there option to force delete folder even if not empty?

Hi @alltej - You need to delete the contents of the folder and then delete the folder. a non empty folders can not be removed from QuickSight Cli. You need to develop a custom code to list all datasets, analysis, and dashboard in that folder and remove them first and then you can clean the folder. It is an iterative process.

Deleting objects via cli is a risk to ensure your correct artifacts should NOT be deleted.
Regards - Sanjeeb

Hi @alltej - as it stands today, you need to remove the assets from the folder before you can delete the folder itself. Using the API you would call the list-folder-members command to get all the assets within that folder, then iterate through them using delete-folder-membership until it is empty. Finally you can delete the folder using delete-folder.

To be clear, this does not delete the assets themselves, it just removes them from the folder.


I call list-folder-members and was expecting to see entries in the FolderPath list in response. But it is empty (). What could me from seeing the contents/members?

Ignore my last reply. Looks like it got deleted already in my previous call, hence the FolderPath was empty. Thanks for the quick reply!

1 Like

Thank you @alltej . Since your issue is resolved, can you marked the require suggestion as solution so that it will help wider community.

Regards - Sanjeeb