0

I am working on changing the files name in google forms But I'm having a problem in the first quarter of work "Exceeded maximum execution time" Can anyone help me?

here are approximately 3,200 requests on Google Forms I can only edit about 100 requests Can the code be modified to run a waiting period and start from where it ends? Or a code that can check the file name if it matches the name of the form, it will skip to make the work faster

 function renamefile() {
var form = FormApp.openById('16aPNgaSuDSk9Z-e0ibwW7_MU_iUP9uQHE'); //DDD
var formResponses = form.getResponses();
var baseString = 'https://drive.google.com/file/d/';
var endString = '/view?usp=drivesdk';
var folder = DriveApp.getFolderById('1rWrGyQttvo6gUrm41kZq09D1r40Zsv4MUo1LcocVguBSfMSbeiDZy-QBcgDZ1t7FFK');
var files = folder.getFiles();
 
 
  while (files.hasNext()) {
    var file = files.next();
    for (var i = 0; i < formResponses.length; i++) {
      var formResponse = formResponses[i];
      var itemResponses = formResponse.getItemResponses();
      var itemResponseFname = itemResponses[1];
      var itemResponsePhoto = itemResponses[14];
            var photoID = itemResponsePhoto.getResponse();
      var newName = itemResponseFname.getResponse() +  " - " + "file"  ;
      var url = baseString + photoID + endString;
      var urlCheck = file.getUrl();
      
      if ( url == urlCheck) {
        var modName = newName + ".pdf" ;
        file.setName(modName);
        console.log()
        

      }
    }
  }
}
  • Welcome to [so]. There are already a huge amount of questions about the "Exceeded maximum execution time". In this case there isn't too much to do to reduce the execution time of your script, so you have to process forms - files in batches. Please spend some time looking at the linked questions. If you need further help, please add more details like the number for forms to processed, if you could put all the forms and their folders inside a folder, etc. If the case result to require too much code the best that you can get in an answer is some guidance / pointers. – Rubén Sep 18 '22 at 15:21

0 Answers0