Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
_shintaku_
4 years agoExplorer | Level 3
Calculate folder size to identify empty/0 bytes folders using python API
Am trying to implement an API automation process to identify empty/0 bytes folders so I can delete them, similar to what was asked here.
I can't find 'size' attribute for folders in my requests response, my code is:-
import requests
import json
url = "https://api.dropboxapi.com/2/files/list_folder"
headers = {
"Authorization": "Bearer <access-token>",
"Content-Type": "application/json"
}
data = {
"path": "/Cat Watching Test",
"recursive": True
}
r = requests.post(url, headers=headers, data=json.dumps(data))
How do I calculate the size of folders from the API?
2 Replies
- Здравко4 years agoLegendary | Level 20
_shintaku_ wrote:...
I can't find 'size' attribute for folders in my requests response, my code is:-
...
Hi _shintaku_,
You can't find 'size' attribute cosa there is NOT such. Only files eventually residing in particular folder have such attribute on enumeration. To calculate total size, you need to enumerate entire folder content recursively and sum all files size (I'm still not certain that you need it actually).
You task can get up much easier if you check only for available entries in particular folder. If there are no any entries (files or folders) the folder is... empty. Isn't it much easier (no recursion, no calculations, etc)? On the post you provide link to, Greg posted some additional helpful tips, able to help automation for such a process (changes detection). Is something left no clear there?
Hope this helps.
- _shintaku_4 years agoExplorer | Level 3
Thanks.
Your suggestion on checking folder for entries was what I used.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!