Via API
You can use the Admin API to delete all resources 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){});Source: https://cloudinary.com/documentation/admin_api#delete_resources
More information here.
Via UI
Bulk Delete Tool
Where can you find it?
- Go to account settings here.
- In the right-hand panel under "Support Activities" select "Bulk delete"
- Follow the steps here, where prefix is the folder path.
- After you click next, submit the bulk delete request
- An email notification will be sent out when the job is complete.
Select assets via the UI manually
Note that you can also bulk select resources in the media library and delete them, e.g., by clicking the first image's checkbox, hold the SHIFT button and check the last image, then click the "Delete" icon.
Note that if you have those images backed up, this will only delete the original images. For deleting backed up resources, 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.