You can delete a folder in the Media library.
This can be done by choosing the folder and clicking on the three dots next to it. Then you can choose delete. please note that you can delete a folder with up to 1000 assets.
If the folder has more than 1000 assets, you can use our bulk delete tool and delete all the assets with the same prefix (folder name) as explained in the following article: How to delete all images within a folder?
When the assets are deleted, you can use the following Python code to delete the empty subfolders:
to_delete=[]
res = cloudinary.api.subfolders("Folder")
for resource in res['folders']:
to_delete.append(resource['path'])
continue
i = 0
while i < len(to_delete):
print(to_delete[i])
cloudinary.api.delete_folder(to_delete[i])
i += 1
Comments
10 comments
I just tried to delete an empty folder from the media library. But this fails, I just get this following pop-up over and over again:
"Confirm Deletion
Are you sure you want to delete this folder?"
Hi,
Can't see an empty folder on your account.
Did you succeed deleting it?
If you're still encountering an issue, please share some more information regarding the exact folder so we can check it out on your account,
If you care about privacy, please feel free opening a support ticket:
http://support.cloudinary.com/tickets/new
Thanks for for your assistance.
I finally managed to delete the folder, some hour later.
The folder had been renamed earlier on (implicitly, by renaming an image). May a cache somewhere that does not properly invalidate?
I'm having a problem with this. The folders(s) that I'm trying to delete via the trash can icon in the admin are empty but it appears that the AJAX is making a call to an incorrect URL:
DELETE https://cloudinary.com/console/media_library/subfolders 404 (Not Found)
I suspect that the lookup for the specified folder is failing and returning this 404 error because hitting the above URL successfully redirects to https://cloudinary.com/console/media_library
I inspected the path being sent in the form data of the AJAX request and it appears to be correct but it's a relative path instead of an absolute path. I'm not sure if that would make any difference on the backend.
Seems like you're trying to delete a folder that contains backups of previously deleted resources. If you wish to clear your backup, please contact us via support@cloudinary.com
We'll look into improving the messaging in such error cases.
Unable to delete my empty folder. Please help me to fix this. Thanks,
Hi Vanitha, if the folder contains backup entries for deleted resources then it cannot be deleted. In order to fully delete the folder, these backup entries need to be deleted as well. Please open a support ticket with all the relevant information (your cloud name and folders name) and we'll be glad to help with that.
We run a regularly scheduled housekeeping job to delete any resources from our Cloudinary library that are no longer in use in our application but were for one reason or another not deleted at the appropriate time.
For this we essentially retrieve the full list of resources by prefix, compare their publicIds against those in our application database and then use the bulk deletion API call. We also make heavy use of folders in our library, and in many cases when we delete a resource,we are left with an empty folder or tree of folders.
I know there is an admin API method to explicitly delete empty folders, but to do so requires yet more IMO unnecessary API queries. Instead, it would be great to have the option, as an optional parameter in the delete resources API call, to automatically delete any empty folders left behind after deleting resources.
I'd actually submit this as a feature request/suggestion, but the "Submit Feature" link in this Support area doesn't seem to work, and only takes you to the Roadmap screen.
Hi
Its possible delete folder from iOS SDK?
I have try this code to delete folder... No Error, but result = "Not found"
do you any suggestion?
thanks
Young
----------------------------------------------------------
let config = CLDConfiguration(cloudName: "NAME", apiKey: "KEY")
let result = cloudinary.createManagementApi()
.destroy("PARENT_FOLDER / WANT_TO_DELETE_FOLDER_NAME", params: CLDDestroyRequestParams())
result.response { result, error in
print(result)
}
Hi Young,
Thanks for reaching out.
iOS SDK does not support the deletion of folders currently and although you can delete specific assets via the method you included in your comment - we strongly advise against carrying out any admin tasks or anything that requires your API secret in your iOS app itself.
And the reason for this is that you'd need to pass the API secret to the configuration which would expose your secret in the client-side code so anyone could retrieve this and compromise your account/assets.
I would recommend you set up a backend server using one of our backend SDKs which will secure your API secret. This will not only let you delete folders securely but also provide you access to all the other APIs that require authentication.
Please let me know if you have any further questions.
Thanks,
Thomas
Please sign in to leave a comment.