Google AppsScript Fails to Copy Large Files in GoogleDrive

Asked 2 years ago, Updated 2 years ago, 132 views

If you try to use GoogleAppsScript below, you will fail in the copy section.
This script copies all folder files with ID AAA to folder with ID BBB, and moves all folder files with ID AAA to the trash can after the copy process is finished.

When I try to copy a file folder with an ID of AAA to a folder with an ID of BBB, I get the error DriveApp (line 19, file "code") along the way, and only a part of it is copied and most of it fails to copy.

Line 19 corresponds to ffile.makeCopy(file.getName(),dest); 」

The source file is a video file, so it will be about 2 Gbytes per file and about 100 files per day.
I try to move it to a different folder within GoogleDrive once a day.

Also, we have changed the target folder to confirm that small files (PDF, etc.) can be copied without any problems and then deleted.

I have already applied to Google and participated in EarlyAccess Program.
I also have a contract with G Suite business.

If an error is inevitable due to problems such as file size, is it possible to have it copied in a different way?
Or is there any other way to avoid errors?

Thank you for your cooperation.

function myFunction(){
  var folders = DriveApp.getFoldersByName("Video");
  vardest=DriveApp.getFolderById('BBB');
  while(folder.hasNext()){
    var folder = folders.next();
    folderCopy (folder, dest);
  }
  listtrash();
}

function folderCopy(folder,dest){
  var folders = folder.getFolders();
  var files=folder.getFiles();

  while(files.hasNext()){
    var file=files.next();
    // If file.makeCopy(dest); then the file name is ****.
    file.makeCopy(file.getName(), dest);
  }

  while(folder.hasNext()){
    var subFolder=folder.next();
    varfolderName=subFolder.getName();
    varcopyFolder=dest.createFolder(folderName);
    folderCopy(subFolder, copyFolder);
  }  
}

function listtrash(){
  var removefolder=DriveApp.getFolderById('AAA');
  var removefolder=removefolder.next();
  var subfolders=removefolder.getFolders();
  while(subfolders.hasNext()){
  vartrashFolder=subfolders.next();
  US>trashFolder.setTrashed(true)
  }
}

google-apps-script google-drive-sdk

2022-09-30 19:56

1 Answers

GoogleDrive's free plan is limited to 5G capacity, but isn't it stuck in the process of copying?


2022-09-30 19:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.