Chase Cromwell
Chase Cromwell

Reputation: 1088

Transfer LARGE amounts of Google Drive files to another Drive account?

How can I transfer a large folder of video files (~400 GB of basketball game film) from one account to another? I can't just use the "change ownership" tool, as this is from Account A (my school account) to Account B (my personal account). I have access to the Google Takeout tool, but I don't think I can transfer from one Google Drive to another account from there without using another platform in the middle and requiring a full download of things and reupload, which is not practical with this many large files.

(Before there's concerns, all of this data is data I created, and am responsible for; not copyrighted/pirated footage.)

Upvotes: 1

Views: 2040

Answers (2)

Tanaike
Tanaike

Reputation: 201378

I believe your situation and goal as follows.

  • You have the permission for copying for all files in the source Google Drive.
  • The files are put in the specific folder including the nested folders.
  • Your Google Drive (destination folder side) have the enough storage size for copying all files.
  • You want to achieve to copy the all files using a script.

For this, how about this answer? I think that your goal can be achieve using Google Apps Script. The flow of this sample script is as follows.

  1. Retrieve all file IDs from the specific source folder including the nested folders.
  2. Create the batch requests from the retrieved file IDs.
  3. Copy the files to the specific folder in your Google Drive using the files.copy method of Drive API with the batch request.

Usage:

Please do the following flow.

1. Create new project of Google Apps Script.

Sample script of Web Apps is a Google Apps Script. So please create a project of Google Apps Script.

If you want to directly create it, please access to https://script.new/. In this case, if you are not logged in Google, the log in screen is opened. So please log in to Google. By this, the script editor of Google Apps Script is opened.

2. Install a Google Apps Script library.

In this answer, a Google Apps Script library is used. It's BatchRequest. By using this library, the file copy can be done with the asynchronous process. By this, the process cost can be reduced a little than that with the synchronous process.

About the method for installing the library, please check here.

3. Enable Drive API.

Please enable Drive API at Advanced Google services. By this, Drive API is automatically enabled at API console. In this sample script, Drive API v3 is used.

4. Sample script.

Please copy and paste the following script. And please set the source folder ID to sourceFolderId. In your case, the top folder ID of They are in several folders, nested inside of one main folder.. And also, please set the destination folder ID to destinationFolderId. In this case, please set the folder ID in your Google Drive.

function myFunction() {
  const sourceFolderId = "###";  // Please set the source folder ID.
  const destinationFolderId = "###";  // Please set the destination folder ID.


  const getFiles = (id, res = []) => {
    const folder = DriveApp.getFolderById(id);
    const files = folder.getFiles();
    while (files.hasNext()) {
      const file = files.next();
      res.push({name: file.getName(), id: file.getId()})
    }
    let ids = [];
    const folders = folder.getFolders();
    while (folders.hasNext()) ids.push(folders.next().getId());
    if (ids.length > 0) ids.forEach(id => getFiles(id, res));
    return res;
  }
  const files = getFiles(sourceFolderId);
  const limit = 100;
  const split = Math.ceil(files.length / limit);
  for (let i = 0; i < split; i++) {
    const batches = files.splice(0, limit).map(f => ({
      method: "POST",
      endpoint: `https://www.googleapis.com/drive/v3/files/${f.id}/copy?supportsAllDrives=true`,
      requestBody: {name: f.name, parents: [destinationFolderId]},
    }));
    const requests = {batchPath: "batch/drive/v3", requests: batches};
    const result = BatchRequest.Do(requests);
    console.log(result.getContentText());
  }

  // DriveApp.createFile()  // This comment line is used for automatically detecting the scope of `https://www.googleapis.com/auth/drive` with the script editor. So please don't remove this line.
}
  • When you run this function at the script editor, the authorization screen is opened. So please authorize the scopes. By this, the script is run.

Note:

  • In this case, all files are copied to the specific folder of destinationFolderId.
  • Please use this script with enabling V8.
  • If you are the owner of the source account, I think that if the parent folder of the top folder might be able to be directly changed to the folder your account which is the destination folder, the process cost will be the lowest. But in my environment, I cannot test it. So if the data is deleted by that, this is the big problem. So I proposed the method for copying all files.

References:

Upvotes: 5

Peter Smulders
Peter Smulders

Reputation: 109

Way too late for the original question, but there are two "userspace" options, other than download/upload:

1: Share & copy

Share the entire tree (from as high as you can) from account A to account B. In account B, copy the tree, then undo the share. All will be done cloudside, so no downloading is involved.

2: Google Takeout / Transfer

This option requires that your institution has enabled this facility (an addition to the Takeout service) for your account, but if it has done so, you can go to https://takeout.google.com/transfer and point it to Account B. This will transfer all material (mail, files, whatnot) to Account B. Mail will be labeled, Drive files will be placed in a top level folder in de Drive of Account B. NB: this applies only to files that are owned by Account A, so make sure you know what's what and clean up ownership within Domain A beforehand.

Google documentation for this feature

Note: this feature is only available in EDU Workspace accounts and (maybe, I cannot verify) Enterprise level Workspace.

Upvotes: 1

Related Questions