We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
Nprice
3 years agoExplorer | Level 4
#tags in the Python API
Hey! Is it possible to add #tags to files and/or folders using the API? I had a quick scan of the docs but couldn’t find it and the search function doesn’t work. Anyone know?
- 3 years ago
😁 Seems, you haven't read my previous posts. Take a look on them more careful. Can you find the link? 🧐🙂
Nprice
Explorer | Level 4
That’s helpful! Thank you
Maybe you can save me some time: would I get the file URL / access the file using Python and then throw each URL + tags into an API url and call it with requests?
I’m new-ish to Python so any pointers would be appreciated!
Maybe you can save me some time: would I get the file URL / access the file using Python and then throw each URL + tags into an API url and call it with requests?
I’m new-ish to Python so any pointers would be appreciated!
Здравко
3 years agoLegendary | Level 20
To be honest, I'm not sure what you ask me actually. You don't need any URL neither actual file to add a tag. The only thing you need is a regular file path (aside of the tag itself), nothing else. This is the same both when using direct API endpoint access or the same through any Dropbox SDK (including Python). There is nothing Python specific. If you mean something else, clarify your question.
Lucky jump into the deep of programming. 😉
- Nprice3 years agoExplorer | Level 4
Hey! Thank you for the reply and your help. I managed to figure out a lot of what I needed last night.
What I need to do is rename + add hashtags to files based on their path. I got as far as renaming, and that's working. I was having trouble finding the method to add hashtags to a file using the Dropbox SDK.
This is the relevant part of the code where I have access to the file path, variables with the hashtags, and am renaming files to the convention.
# Create new file name from individual tags + incremental count and add file type
new_file_name = f"{photographer_name}_{act_name}_{artist_name}_{genre}_{discipline}_{media_type}_{count}{file_type}".replace(
" ", "").replace("-", "")
# Get new file path by removing old file name from path
new_file_path = "".join(media_file.path_display.rpartition('/')[:-1])
if rename_file_check:
print(f'Renaming {media_file.name} to {new_file_name}')
# Rename file - old file path, new file path
dbx.files_move_v2(media_file.path_display, new_file_path + new_file_name)
# Increment the count to avoid overwriting
count += 1I just wonder if there is a method similar to .files_move_v2 that I can call to add hashtags to each individual file.
- Здравко3 years agoLegendary | Level 20
Nprice wrote:...
I just wonder if there is a method similar to .files_move_v2 that I can call to add hashtags to each individual file.
As far as I know there is not such a combined method. You need to make 2 (or more) consecutive calls to rename and to add tag(s).
- Nprice3 years agoExplorer | Level 4
Yeah, I understand that. I'm just wondering *how* do I add the hashtags? What's the method of dropbox.Dropbox in order to do that?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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 or Facebook.
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!