Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

muratowski's avatar
muratowski
Explorer | Level 4
3 years ago
Solved

Unable to list files in shared Dropbox folder using Python and the Dropbox API

I am trying to use Python and the Dropbox API to list the files in a shared Dropbox folder. Here is my source code: """ import dropbox import os # Replace "ACCESS_TOKEN" with your Dropbox a...
  • Greg-DB's avatar
    Greg-DB
    3 years ago

    The os.listdir method is a Python method for listing the contents of a particular folder on the local filesystem at the specific path. It accesses the files and folders on the device and a FileNotFoundError error from it would indicate that there is nothing at the local path you specified, in this case using the value in the folder_path variable. The method does not call the Dropbox API and is not made by Dropbox though, so Dropbox can't offer support for that in particular.

     

    I see you are getting the folder_path value from the files_list_folder results. That would only work with os.listdir if the path to the relevant folder on your local machine happened to match the path to it inside your Dropbox account.

     

    I don't have full context on your project or the requirements and constraints you're working under of course, so I can't tell you exactly what code you should write. It may be helpful to step through with a debugger to see what each line is doing and update your code accordingly.

     

    It may also be worth mentioning that if you ultimately want to move or rename files or folders in Dropbox, you can do so directly using the Dropbox API (whether or not you have your Dropbox folder synced to your computer locally), without interacting with the local filesystem. To move or rename a file or folder using the Dropbox API via the Dropbox Python SDK, you would use files_move_v2. And as noted earlier, you can use files_list_folder and files_list_folder_continue to list the contents of a folder (even without a shared link, if the content is in your connected Dropbox account). You may also want to check out the Getting Started and File Access guides.

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!