Delete multiple images
Hello!
We use a solution that hosts images on cloudinary and we need to archive and delete the images used for more than 6 months.
Looking at the faq and documentation, we find questions about the mass deleting images.
There are no programmers in our team, making it difficult to use solutions in dotnet, for example.
However, we found a simple, practical and would like to share with you.
We believe that it can help other users.
Download the curl (is a computer software project providing a library and command-line tool for transferring data using various protocols).
Open the Windows command prompt.
Run the command:
curl -v "https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/CLOUD_NAME/resources/image?direction=desc&max_results=1000">c:\temp\images.txtWill be copied the information from the first 1,000 cloudinary images in the file "c:\temp\images.txt"
Copy the text and paste into a text editor (such as Microsoft Word or another text editor such as Notepad ++) and replace the character "}" (without quotation marks) the paragraph mark (in the case of Microsoft Word, are the characters "^p" without quotes)
Copy all the text and paste into a spreadsheet editor (such as Microsoft Excel)
Convert text to columns using the character "," (without quotes)
You will have a table with all the separate images information in table format.
Find the column that has the public id of the images. It has the pattern {"public_id": "imagename"
(in the case of non default type or resource_type or non-conventional naming convention, you must change the pattern according to your need in the steps 9, 10, 11 and 12)Replace the characters { and ". The name should be this: public_ids: imagename
Use the concatenate Microsoft Excel function to keep the following pattern:
(START /B /WAIT curl -v -X DELETE “https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/CLOUD_NAME/resources/image/upload?,public_ids=name”)The result will be:
START /B /WAIT curl -v -X DELETE “https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/CLOUD_NAME/resources/image/upload?public_ids=name”Copy the column that is in the above pattern, paste into Notepad and save it as images.bat. It should be saved in the same folder as the file curl.exe
Open a command prompt and run the file images.bat
All images are the above pattern will be deleted.
Note: We use this procedure to a specific need for our solution. Some additional modifications may be required based on the specific use-case.
Thanks!
-
Hi,
Sorry for the late response.
Deleting resources can be done easily with our Admin API.
You can delete all resources or based on a specific criteria.
If you're not comfortable with this API, please open a support ticket and share your details. We will gladly bulk delete your images for you.0
Post is closed for comments.
Comments
1 comment