We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
sajadjaward1
6 years agoExplorer | Level 4
Batch copy within Dropbox gives an error
Hello All! I am using Dropbox Javascript SDK to manage my files within Dropbox. I have come across a scenario where I need to copy 1 or many files (depends) into a single folder. For this, I ...
- 6 years ago
Yes, you can use this filesCopyBatchV2 method to copy files from multiple different locations into one folder. When doing so though, each 'to_path' shouldn't all be exactly the same. The 'to_path's can all be inside the same folder, but they should include the different file names so they don't conflict with each other.
Greg-DB
Dropbox Community Moderator
6 years agoThis 'failure/relocation_error/to/conflict/folder' error indicates that the operation failed because there is already a folder at the destination path you specified.
Note that when specifying a destination path like this, you should specify the full path where you want to put the item, including both the path of the parent folder, as well as the desired name of the file/folder itself.
In your code, you're setting the destination as `'/Destination/' + randomNum ` for each `file`, and you mentioned "the destination would be the same", so it sounds like this error is to be expected. You will need to set a distinct `to_path` for each item. For example, perhaps you want to do something like:
to_path: '/Destination/' + randomNum + '/' + file
sajadjaward1
6 years agoExplorer | Level 4
Thank you for replying.
Is there any way that I can copy all the files from different paths into a same destination folder? I do not want to end up having so many folders created at the destination for each file that I am copying.
Does Dropbox have an API which supports this method?
Thank you again
- Greg-DB6 years ago
Dropbox Community Moderator
Yes, you can use this filesCopyBatchV2 method to copy files from multiple different locations into one folder. When doing so though, each 'to_path' shouldn't all be exactly the same. The 'to_path's can all be inside the same folder, but they should include the different file names so they don't conflict with each other.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!