Why doesn't the folder info include the number of files in the folder and subfolder. Since it seems to be important enough to show to users, it seems strange that this info would not be included in the folder info object. Is there an alternate approach to querying this information that I'm not seeing?
Hi ,
Yes, you are right. There is no direct reference to folder or file numbers from that API call. But there is indirect way of gettng it. You have to call folder info api and it will show you the 'item_collection' array where you can get 'total_count' of items. However you have to loop through that array to count the folder or file by using the "type" field.
eg.
"item_collection": {
"total_count": 2,
"entries": :
{
"type": "folder",
"id": "xxxxxx",
"sequence_id": "2",
"etag": "2",
"name": "Tyrion Lannister"
},
{
"type": "file",
"id": "xxxxxx",
"sequence_id": "1",
"etag": "1",
"name": "No one.pdf"
}]
As you can see in above e.g. the total_count is 2 with 1 folder and 1 file. But this will only work for the single folder. You have to create your own recrusive function to go through all the folders in depth.
hope this helps.
Bibek
Thanks @Bibek! Yes, I think makes sense.
My interest in the number was actually to write a test for a different program that itself recursively loops through directories and files to create and update a database of file names and their sha1's. I was doing that to be able to check for a given file (if I have its sha1) whether that file already exists on Box.
Anway, I'm sure I can make due with what's available.
Best regards,
Mike
Hi ,
Sure, you can make it happen 🙂 Good luck.
thanks,
Bibek
this is not helpful. I would like to be able to see a file count for every folder in my box directory. not possible? seems like a very basic feature
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.