You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
RogueBotanist
3 years agoExplorer | Level 3
Trouble moving individual file based on selection in listWidget: Python API
Hello,
I'm struggling to interact with a file in a folder based on the selection in a listWidget.
I have verified the selection works as I can remove selected items from the listWidget. I however am having difficult moving the file in dropbox to another folder. Here's my method:
def archive():
itemList = []
currentIndex = listWidget.currentRow()
item = listWidget.item(currentIndex)
for x in dbx.files_list_folder('/Testing Application').entries:
itemList.append(str(x.name))
dbx.files_move(from_path ='/Testing Application',to_path= '/Archived', autorename=False)
item = listWidget.takeItem(currentIndex)
del item
Here is how I listed the files in the listWidget:
activeList = []
for item in dbx.files_list_folder('/Testing Application').entries:
cell = QListWidgetItem(str(item.name))
activeList.append(str(item.name))
listWidget.addItems(activeList)
So I know I only have the name and I need to connect the selection of the name back to the original file. I could just do that by index, if index[list] = index[dbx] Move file.
But I am having difficulty moving the file. I have my selection mode in the app set to singleSelection so currently it throws an error because it's trying to move everything in the folder. When it was set to multiSelection it moved everything.
Need help selecting an individual file and moving just that one file.
- ЗдравкоLegendary | Level 20
RogueBotanist wrote:...
dbx.files_move(from_path ='/Testing Application',to_path= '/Archived', autorename=False)...
But I am having difficulty moving the file. I have my selection mode in the app set to singleSelection so currently it throws an error because it's trying to move everything in the folder. When it was set to multiSelection it moved everything.
...
Hi RogueBotanist,
😁 No, no,... it doesn't "moved everything"; it does "moved" just one thing - the folder itself. 😉 You just haven't pointed anything else; it's always the folder itself. The source and destination of move have to be full path to the target - either file or folder (it's file in your case) in both places.
Hope this helps.
- Greg-DBDropbox Staff
RogueBotanist As Здравко noted, the code you shared is written to move the folder itself. If you want to move a specific file, you need to set the from_path parameter to be the whole path, including file name, to the file that you want to move. Likewise, the to_path parameter needs to the be whole path, including file name, where you want to move the file.
The 'entries' list in the ListFolderResult returned by files_list_folder/files_list_folder_continue is a list of Metadata, so you can get the full path for any particular item from the Metadata.path_lower field.
Also, note that the newer files_move_v2 method is preferred over files_move.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days 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!