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?
😁 Seems, you haven't read my previous posts. Take a look on them more careful. Can you find the link? 🧐🙂
Hi @Nprice,
Take a look here: https://www.dropbox.com/developers/documentation/http/documentation#files-tags-add 😉 for API end-point.
Hope this helps.
For Dropbox Python SDK method take a look here.
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. 😉
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 typenew_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 pathnew_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 += 1
I just wonder if there is a method similar to .files_move_v2 that I can call to add hashtags to each individual file.
@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).
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?
Is it this? dropbox.files.AddTagArg()
https://dropbox-sdk-python.readthedocs.io/en/latest/api/files.html