I am trying to create a script that shows the name of the images in a dropbox directory and the time they were added to the folder. To do that I have created gama[entry] that has all the names of the images in that directory. My problem is I don't know how to add those names in the directory in order to produce the metadata. The script below can't work for that reason. How can I add it?
import dropbox
dbx = dropbox.Dropbox('ACCESS_TOKEN')
gama={}
dbx.users_get_current_account()
for entry in dbx.files_list_folder('/photos').entries:
gama[entry]= entry.name
print('gama=', gama[entry])
print(entry.name)
x= dbx.files_get_metadata('/photos/gama[entry]').server_modified
print(x)
In this line, you're putting the actual string "gama[entry]" into the path, instead of the value of the variable with that name:
x= dbx.files_get_metadata('/photos/gama[entry]').server_modified
You probably meant to do something like this instead:
x= dbx.files_get_metadata('/photos/%s' % gama[entry]).server_modified
Or, more directly, without the gama
variable, that's equivalent to:
x= dbx.files_get_metadata('/photos/%s' % entry.name).server_modified
Note that you actually don't need the files_get_metadata
call anyway though. The files_list_folder
method gives you the same metadata to begin with, so you can just do:
x= entry.server_modified