google-apps-script DriveApp Get all files - put them into a continuation token - then retrieve them

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

 function processGoogleDriveFiles() {
  var arrayAllFileNames,continuationToken,files,filesFromToken,fileIterator,thisFile;//Declare variable names
  
  arrayAllFileNames = [];//Create an empty array and assign it to this variable name
  
  files = DriveApp.getFiles();//Get all files from Google Drive in this account
  continuationToken = files.getContinuationToken();//Get the continuation token
  
  Utilities.sleep(18000);//Pause the code for 3 seconds
  
  filesFromToken = DriveApp.continueFileIterator(continuationToken);//Get the original files stored in the token
  files = null;//Delete the files that were stored in the original variable, to prove that the continuation token is working
  
  while (filesFromToken.hasNext()) {//If there is a next file, then continue looping
    thisFile = filesFromToken.next();//Get the next file
    arrayAllFileNames.push(thisFile.getName());//Get the name of the next file
  };
  
  Logger.log(arrayAllFileNames);  
};


Got any google-apps-script Question?