Via API
You can use the Admin API to delete all assets contained within a specific folder, including sub-folders.
Here's an example in Node.js:
cloudinary.api.delete_resources_by_prefix('my_folder/', function(result){});
Please note that the /
after my_folder
needs to be included, as it is considered part of the prefix.
More information about the Admin API delete methods can be found in the Admin API documentation.
Via UI
1) Bulk Delete Tool
- Navigate to the bulk delete section found in the right navigation bar in your account settings view.
- Select the
originals and derived resources
option, thenprefix
as theSearch by
option. The prefix is the folder path followed by a slash/
at the end e.g.folder1/folder2/
. - Select the specific
resource_type
andtype
of assets you want to delete. - For those with automatic backups enabled, select whether you'd like to clear the backed up versions of the assets to be deleted.
- Click "Next"; you will be prompted to enter your password to submit the bulk delete request. An email notification will be sent once the process has completed.
2) Select and delete assets manually
To delete assets manually, you can do one of the following to select the assets to delete:
- Option 1: bulk select assets by clicking the checkbox in the top left corner of an asset to designate a "starting point" , then hold down shift while clicking the checkbox of another asset to select that asset and every asset in between.
- Option 2: click individual asset checkboxes to select them for deletion.
When the assets are selected, click on the Delete button in the toolbar.
Here is a short video demonstrating the above:
Note that if you have these assets backed up, this will only delete the original assets. For deleting backed up assets, please contact our support team and we'll be happy to assist.
Comments
11 comments
Can you show us an example in Java?
It (api.deleteResourcesByPrefix) does not work with Scala to delete a folder. Only "image" and "raw" can be defined to the resourceType. Does anyone have any idea?
Hi,
Sorry for the very late reply, we have noticed that this request was left unattended. I guess this is not relevant anymore but for future reference -
deleteResourcesByPrefix is meant to delete resources within a certain folder. Deleting the folders is currently not supported on our SDKs (it's currently on our road map). Please note that you can delete empty folders using the console.
works great.
Hello,
Fast forward to March 2019. Is it possible to now delete the folder as well. Currently it only deletes files inside the 'mySubfolder' folder. Leaving an empty folder behind seems incomplete for what I'm trying to do.
Hi Gar,
You can make a second call to remove the folders, there's an API method for this but it doesn't currently have a corresponding helper method in the SDKs - the HTTP endpoint is an HTTP DELETE call to
`<API key>:<API_SECRET>@https://api.cloudinary.com/v1_1/<cloud_name>/folders/<folder> `
You can use that to delete the empty folders. There's a task on our roadmap to add this to the SDK directly, but I'm afraid I don't have an ETA for when it will be available
Hi Stephen,
Thanks for getting back. I'm not very familiar with how to implement your solution. Do I do this in the Terminal?
I would like to perform the delete folder on the server using Node. Is that possible? If so can you provide a snippet please?
Thanks,
Gar
Hi Gar,
There isn't a specific method for this in our Node SDK yet, but you can call the endpoint directly using any HTTP library of your choice.
For example, with the 'request' module ( https://github.com/request ), you can delete an empty folder like this:
When I tested this, the 'body; output was:
deleted: [ 'tmp/folders/delete' ]
Amazing!!!!
Tried it and it works. Thanks so much Stephen!
You're welcome; if you need anything else please let me know, and you can always open a support ticket for my team directly via http://support.cloudinary.com
@Stephen Doyle Thank you! Best solid node.js answer I could find online. Thank you again.
Please sign in to leave a comment.