Skip to main content
fixed numbered list format
Source Link
  1. Copy this into Google Apps script (script.google.com), doesn't matter on which account.

    Copy this into Google Apps script (script.google.com), doesn't matter on which account.
  2. Click on the source folder, click Share, and then advanced. Copy the link's key into the "..." for the source.

    Click on the source folder, click Share, and then advanced. Copy the link's key into the "..." for the source.
  3. Do the same for the destination folder.

    Do the same for the destination folder.
  4. Run it how many times you want.

    function start() {

    var originFolder = DriveApp.getFolderById("..."); var destination = DriveApp.getFolderById("...");

    copyFolder(originFolder, destination);

    }

    function copyFolder(source, target) {

    var folders = source.getFolders(); var files = source.getFiles();

    while(files.hasNext()) { var file = files.next(); var dest = target.getFilesByName(file.getName()); if (dest.hasNext()) { // skip because file exists Logger.log('skipping copy for ' + file.getName() + ' because it exists.'); continue; }

     Logger.log("copying file: " + file.getName());
     file.makeCopy(file.getName(), target);
    

    }

    while(folders.hasNext()) { var subFolder = folders.next(); var folderName = subFolder.getName();

     var dest = target.getFoldersByName(folderName);
     var targetFolder;
     if (!dest.hasNext()) {
       Logger.log('creating folder ' + folderName);
       targetFolder = target.createFolder(folderName);
     } else {
       targetFolder = dest.next();
     }
    
     copyFolder(subFolder, targetFolder);
    

    }

    }

    Run it how many times you want.
function start() {
  
  var originFolder = DriveApp.getFolderById("...");
  var destination = DriveApp.getFolderById("...");
  
  copyFolder(originFolder, destination);
    
}

function copyFolder(source, target) {

  var folders = source.getFolders();
  var files   = source.getFiles();
  
  while(files.hasNext()) {
    var file = files.next();
    var dest = target.getFilesByName(file.getName());
    if (dest.hasNext()) {
      // skip because file exists
      Logger.log('skipping copy for ' + file.getName() + ' because it exists.');
      continue;
    }
    
    Logger.log("copying file: " + file.getName());
    file.makeCopy(file.getName(), target);
  }
  
  while(folders.hasNext()) {
    var subFolder = folders.next();
    var folderName = subFolder.getName();
    
    var dest = target.getFoldersByName(folderName);
    var targetFolder;
    if (!dest.hasNext()) {
      Logger.log('creating folder ' + folderName);
      targetFolder = target.createFolder(folderName);
    } else {
      targetFolder = dest.next();
    }
    
    copyFolder(subFolder, targetFolder);
  }  
  
}
  1. Copy this into Google Apps script (script.google.com), doesn't matter on which account.

  2. Click on the source folder, click Share, and then advanced. Copy the link's key into the "..." for the source.

  3. Do the same for the destination folder.

  4. Run it how many times you want.

    function start() {

    var originFolder = DriveApp.getFolderById("..."); var destination = DriveApp.getFolderById("...");

    copyFolder(originFolder, destination);

    }

    function copyFolder(source, target) {

    var folders = source.getFolders(); var files = source.getFiles();

    while(files.hasNext()) { var file = files.next(); var dest = target.getFilesByName(file.getName()); if (dest.hasNext()) { // skip because file exists Logger.log('skipping copy for ' + file.getName() + ' because it exists.'); continue; }

     Logger.log("copying file: " + file.getName());
     file.makeCopy(file.getName(), target);
    

    }

    while(folders.hasNext()) { var subFolder = folders.next(); var folderName = subFolder.getName();

     var dest = target.getFoldersByName(folderName);
     var targetFolder;
     if (!dest.hasNext()) {
       Logger.log('creating folder ' + folderName);
       targetFolder = target.createFolder(folderName);
     } else {
       targetFolder = dest.next();
     }
    
     copyFolder(subFolder, targetFolder);
    

    }

    }

  1. Copy this into Google Apps script (script.google.com), doesn't matter on which account.
  2. Click on the source folder, click Share, and then advanced. Copy the link's key into the "..." for the source.
  3. Do the same for the destination folder.
  4. Run it how many times you want.
function start() {
  
  var originFolder = DriveApp.getFolderById("...");
  var destination = DriveApp.getFolderById("...");
  
  copyFolder(originFolder, destination);
    
}

function copyFolder(source, target) {

  var folders = source.getFolders();
  var files   = source.getFiles();
  
  while(files.hasNext()) {
    var file = files.next();
    var dest = target.getFilesByName(file.getName());
    if (dest.hasNext()) {
      // skip because file exists
      Logger.log('skipping copy for ' + file.getName() + ' because it exists.');
      continue;
    }
    
    Logger.log("copying file: " + file.getName());
    file.makeCopy(file.getName(), target);
  }
  
  while(folders.hasNext()) {
    var subFolder = folders.next();
    var folderName = subFolder.getName();
    
    var dest = target.getFoldersByName(folderName);
    var targetFolder;
    if (!dest.hasNext()) {
      Logger.log('creating folder ' + folderName);
      targetFolder = target.createFolder(folderName);
    } else {
      targetFolder = dest.next();
    }
    
    copyFolder(subFolder, targetFolder);
  }  
  
}
Source Link

The only way I found to do it is by writing a script on my own. It will time out, and then you will need to restart the script. I wrote it so that it won't be a problem to restart the script.

  1. Copy this into Google Apps script (script.google.com), doesn't matter on which account.

  2. Click on the source folder, click Share, and then advanced. Copy the link's key into the "..." for the source.

  3. Do the same for the destination folder.

  4. Run it how many times you want.

    function start() {

    var originFolder = DriveApp.getFolderById("..."); var destination = DriveApp.getFolderById("...");

    copyFolder(originFolder, destination);

    }

    function copyFolder(source, target) {

    var folders = source.getFolders(); var files = source.getFiles();

    while(files.hasNext()) { var file = files.next(); var dest = target.getFilesByName(file.getName()); if (dest.hasNext()) { // skip because file exists Logger.log('skipping copy for ' + file.getName() + ' because it exists.'); continue; }

     Logger.log("copying file: " + file.getName());
     file.makeCopy(file.getName(), target);
    

    }

    while(folders.hasNext()) { var subFolder = folders.next(); var folderName = subFolder.getName();

     var dest = target.getFoldersByName(folderName);
     var targetFolder;
     if (!dest.hasNext()) {
       Logger.log('creating folder ' + folderName);
       targetFolder = target.createFolder(folderName);
     } else {
       targetFolder = dest.next();
     }
    
     copyFolder(subFolder, targetFolder);
    

    }

    }