How to find all empty folders?
Hi,
How to find all empty folders with API to delete them later?
The following expressions `folder=images/*` returns only files, not subfolders (empty subfolders).
-
Hello,It looks like you are already aware of how to search for assets in a folder as well as subfolders using the Search API. You are correct here as it will only return files and not subfolders. If there are no results using that expression, then the folder (and subfolder) is empty.You might also want to consider using the Api.subfolders method to list the name and path of all subfolders. That can be found here:We have an API method for deleting empty folders, see the link below for the syntax and examples:Please let me know if this helps.Thanks,Bryan1
-
Hi Bryan,
Thank you. It works! I removed all empty folders by combining 3 methods.
Additional questions:
1. How to pass optional parameters to https://cloudinary.com/documentation/admin_api#get_subfolders in NodeJS
2. This approach requires a lot of API calls. How to get around the rate limits?
0 -
Hello,
1) We provide an example in Node.JS in the link you referenced. For example, in Node.js:
cloudinary.v2.api.sub_folders(folder, options, callback);
So for example, List all subfolders of a given folder 'product/shoe':
cloudinary.v2.api.sub_folders("product/shoe", function(error, result){console.log(result);});
The link you have referenced here (https://cloudinary.com/documentation/admin_api#get_subfolders)
Mentions the additional parameters max_results & next_cursor which can be passed as optional parameters. Description of those two parameters are in the link above.
2) Yes, our API calls have an hourly rate limit. Specific limits depend on the level of your account. For example, a free account has 500 requests allowed per hour. With a paid account you will receive a higher rate limit.
0
Post is closed for comments.
Comments
3 comments