E
E
EastJesus2018-03-24 23:23:14
Google Drive
EastJesus, 2018-03-24 23:23:14

Google Script maximum execution time exceeded, how to solve?

Good evening everyone, with the help of a script I want to copy folders on a Google drive, after a while it gives an error that the maximum script execution time has been exceeded. Can I increase this time or continue from where I started? The code itself:

function start() {

  var sourceFolder = "Product";
  var targetFolder = "2";

  var source = DriveApp.getFoldersByName(sourceFolder);
  var target = DriveApp.createFolder(targetFolder);

  if (source.hasNext()) {
    copyFolder(source.next(), target);
  }

}

function copyFolder(source, target) {

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

  while(files.hasNext()) {
    var file = files.next();
    file.makeCopy(file.getName(), target);
  }

  while(folders.hasNext()) {
    var subFolder = folders.next();
    var folderName = subFolder.getName();
    var targetFolder = target.createFolder(folderName);
    copyFolder(subFolder, targetFolder);

  }  

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2018-03-25
@oshliaer

Your question is here Maximum Google Script Execution Time
In addition, do not correspond on other issues.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question