Forum Discussion

LRomano's avatar
LRomano
Explorer | Level 3
6 years ago

Re: Dropbox API not returning all files

Hey Greg,

 

I've tried to adapt this code in order to get a bunch of files that begin with the letters 'zas', but I found the script just ran for hours without any luck, so I stripped it back to see what was happening.

 

I define my root and result:

root_path = '/MarketingCreative/External/Bidalgo_Zynga_CSR2/'

result = dbx.files_list_folder(root_path, recursive=True)

And then I'm just printing the file name if its a file, and the folder name if it's a folder:

 

def process_entries(entries):
  for entry in entries:
    if isinstance(entry, dropbox.files.FileMetadata):
      file = entry.path_display.rsplit('/', 1)[1]
      print(file)
    else:
      print("Folder "+entry.path_display)

process_entries(result.entries)

while result.has_more:
  result = dbx.files_list_folder_continue(result.cursor)
  process_entries(result.entries)

Again, this is just to see why the script is taking so long with no results.

 

It seems that after the first few files, the script just keeps repeating the root folder, and not progressing the the subfolders (and files) within (see photos).

 

 

If I specific a sub folder in the root path, eg:

root_path = '/MarketingCreative/External/Bidalgo_Zynga_CSR2/C2_112118_2.1_FormulaItalia3_Trailer_VS_AlfaRomeo_[LOC]/'

result = dbx.files_list_folder(root_path, recursive=True)

The script does what I need it to, but at this one level up, it seems to be an infinite loop.

 

How could I go about debugging this? Is it a cursor issue do you think?

 

Thanks

 

11 Replies

About Dropbox API Support & Feedback

Node avatar for 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!