We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Dario_Go's avatar
Dario_Go
Explorer | Level 3
8 years ago

Correct Way to move folders in batch mode Java API

Hi. I need to move a lot of folders with files to another shared folder. I need to do that every day using Java API

 

But moving a got the messsage "too_many_write_operations". I read in the doc that we need to do that in batch mode.

 

Someone have a example to do that?

 

Thanks in advance.

 

Regards,

Dario.

  • To move items in bulk using the Dropbox API v2 Java SDK, you should use moveBatch (or moveBatchBuilder) and moveBatchCheck.

     

    We don't have a full example of that, but it would look like this:

     

    List<RelocationPath> entries = new ArrayList<RelocationPath>();
    entries.add(new RelocationPath("/folder1_original_path", "/folder1_new_path"));
    entries.add(new RelocationPath("/folder2_original_path", "/folder2_new_path"));
    // ... and so on
    
    RelocationBatchLaunch moveBatchJob = client.files().moveBatch(entries);
    
    RelocationBatchJobStatus moveBatchCheck = null;
    
    while (moveBatchCheck == null || moveBatchCheck.isInProgress()) {
        // check this occasionally until it's done
        moveBatchCheck = client.files().moveBatchCheck(moveBatchJob.getAsyncJobIdValue());
        System.out.println(moveBatchCheck);
        Thread.sleep(10000);
    }
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    To move items in bulk using the Dropbox API v2 Java SDK, you should use moveBatch (or moveBatchBuilder) and moveBatchCheck.

     

    We don't have a full example of that, but it would look like this:

     

    List<RelocationPath> entries = new ArrayList<RelocationPath>();
    entries.add(new RelocationPath("/folder1_original_path", "/folder1_new_path"));
    entries.add(new RelocationPath("/folder2_original_path", "/folder2_new_path"));
    // ... and so on
    
    RelocationBatchLaunch moveBatchJob = client.files().moveBatch(entries);
    
    RelocationBatchJobStatus moveBatchCheck = null;
    
    while (moveBatchCheck == null || moveBatchCheck.isInProgress()) {
        // check this occasionally until it's done
        moveBatchCheck = client.files().moveBatchCheck(moveBatchJob.getAsyncJobIdValue());
        System.out.println(moveBatchCheck);
        Thread.sleep(10000);
    }

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 12 months ago
325 Following

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 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!