1

I use the Google Apps Script function DriveApp to iterate through 425 folders. The function handles one folder each run and saves the continuationToken as a UserProperty. It runs every minute.

My problem is that after many runs (~300) the continuationToken is the same as the previous one making a loop that I cant get past.

I have made this script in many different ways but the token-issue always occur and for different folders. Even when I handled multiple folders per run.

This is basically what I do:

function name(){
  var proper = PropertiesService.getUserProperties();
  var alla = proper.getProperty('addLoop');
  if(alla == "")
    alla = DriveApp.getFolderById("ID").getFolders();
  else
    alla = DriveApp.continueFolderIterator(alla);

  if(alla.hasNext()){
    var next = alla.next();
    proper.setProperty('addLoop', alla.getContinuationToken());
    functionName(next);
  }
  else
    proper.setProperty('addLoop', "");
}

I can't believe this is a scripting-error but i haven't read of any limitation for this usage of the Apps Script either... I'm clueless and happy for any input.

Niklas Ternvall
  • 510
  • 1
  • 3
  • 19
  • possible duplicate of [Iterators built with different continuation tokens are producing the same results in Google Apps](http://stackoverflow.com/questions/24375883/iterators-built-with-different-continuation-tokens-are-producing-the-same-result) – Serge insas Jun 27 '14 at 16:12
  • You can't get the token before looping. Here's the [how to use it correctly](http://stackoverflow.com/questions/22365681/correct-usage-of-driveapp-continuefileiteratorcontinuationtoken) – Henrique G. Abreu Jun 28 '14 at 13:41
  • Right. I made a duplicate and the question remains unanswered there as well. – Niklas Ternvall Jun 30 '14 at 10:47

0 Answers0