title: Google sheet script timeout error
body: <p>I'm trying to get file names and IDs from images and there are more than 3000 images and the number will just keep adding.</p>
  
  <p>I have this piece of code online that works pretty well. However the problem is that the script will always timeout before it can finish getting all the images.</p>
  
  <p>So I'm wondering if there's a way to continue from where from the last session.
  I know there are many answers addressing session timeout problems but my javascript isn't proficient enough to figure out how to write them.</p>
  
  <p>Thanks</p>
  
  <p>Here's the code I have</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("ID");
      var contents = folder.getFiles();
  
      var cnt = 0;
      var file;
  
      while (contents.hasNext()) {
          var file = contents.next();
          cnt++;
              data = [
                  file.getName(),
                  file.getId(),
              ];
              sheet.appendRow(data);
      };
  };
  </code></pre>