title: Google Script timeout after 6 min
body: <p>I want to list all the folderName and their folderID present in a team Drive(more than 3000 folders). I am using speedsheet and running following code in script-</p>
  <pre><code>function listFilesInFolder(folderName) {
  
     var sheet = SpreadsheetApp.getActiveSheet();
     sheet.appendRow(['Name','File-Id']);
  
  
  //change the folder ID below to reflect your folder's ID (look in the URL when you're in your folder)
      var folder = DriveApp.getFolderById('folder ID');
      var contents = folder.getFolders();
  
      var cnt = 0;
      var folder;
  
      while (contents.hasNext()) {
          var folder = contents.next();
          cnt++;
  
             data = [
                  folder.getName(),
                  folder.getId(),
              ];
  
              sheet.appendRow(data);
      };
  }
  </code></pre>
  <p>But this is getting Error Exceeded maximum execution time which is 6 min by default.</p>
  <p>I tried adding triggers from script app, but after triggering it get start from beginning and script still ends after 6min.</p>
  <p>How to add a triggers which starts from where it left?</p>