cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select, Move, and Output a Random Image from a Folder?

Select, Move, and Output a Random Image from a Folder?

Cyrin
New member | Level 2

Hello Dropbox developer community,
I would like to start by saying that I'm very new to the useage of the Dropbox API (and, to be honest, Python in general). However, I am in the process of attempting to create a script for a bot for a chat service known as "Discord". My goal is to have two folders in my App's master folder: a "Queue" folder, and a "Previous" folder. My goal is to have my code select a random image from the "Queue" folder, have the Discord module upload the file to the chat rooms —aka servers— that it is in, and finally move the selected image to the "Previous" folder. So I guess what I'm asking is this: Is it possible to select a random image from a folder, then remember that image until it is done being used?

1 Reply 1

Greg-DB
Dropbox Staff

The Dropbox API does offer an official Python SDK with the ability to list, download, and upload files, among other operations, so this certainly should be possible. 

 

For instance, you could use files_list_folder and files_list_folder_continue to list the contents of any desired Dropbox folder (e.g., "/Queue") and then randomly choose one of the entries in the list. You could then get the file data using files_download, and move the file when you're done with it using files_move.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?