Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:29:44+00:00 2026-06-13T23:29:44+00:00

I note the new Docslist Token and get*ForPaging() options available now but I am

  • 0

I note the new Docslist Token and get*ForPaging() options available now but I am still struggling with an algorithm to process “all files and folders” for arbitrarily large file/folder trees.

Assume a Google Drive based web file system with n files and folders. It will take multiple runs of 6 minutes to get through with a Google Apps Script. Nightly I need to process all files older than 30 days in trees of subfolders beneath a starting folder. I need to process each file once only (but my functions are idempotent so I don’t mind if I run against files again).

I have my recursive algo working but the thing that I am missing is a way to have a placeholder so that I don’t have to start at the top of the folder tree each time I invoke the script. In six minutes I get through only a few hundred folders and a few thousand files.

My question is what index can I store and how do I start where I left off the next time through?

I have thought about storing Tokens or the last completed folder path “/mytop/sub4/subsub47/” but how would that help me on another invocation? If I started there it would falsely just work down the tree from there and miss siblings and ancestor folders.

I have thought about the “find” methods and using a “before:2012/10…” style search but there’s no way to limit that to files in my tree (only a single folder).

I am not pasting my code as it’s just standard recursive getFolders/getFiles and not actually relevant to the core of the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:29:45+00:00Added an answer on June 13, 2026 at 11:29 pm

    I’d create an array of the folders that I have to work on and save it all for a future run.
    Since you said it’s no problem to work on some files/folders repeatedly, you don’t even need to put a fake stop to your function. You can let it timeout every time.

    Something like this:

    var folders = null;
    
    //call this to start the process or set the property manually
    function start() {
      folders = ['id-of-the-starting-folder'];
      work();
    }
    
    //set this to run on the trigger
    function work() {
      if( folders == null )
        folders = ScriptProperties.getProperty('folders').split(',');
    
      while( folders.length > 0 ) {
        workOnFolder(folders[0]);
        folders.shift(); //remove the 1st element
        ScriptProperties.setProperty('folders', folders.join());
      }
      //remove the trigger here
    }
    
    function doFolderLater(folder) {
      folders.push(folder.getId());
    }
    
    function workOnFolder(id) {
      var folder = DocsList.getFolderById(id);
      folder.getFolders().forEach(doFolderLater);
      folder.getFiles().forEach(workOnFile);
    }
    
    function workOnFile(file) {
      //do your thing
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: new to mysql I am trying to get points from user id (
this code is correct?? String note = text.txt; FileWriter file = new FileWriter(note); Scanner
NOTE: I added my new solution at the UPDATE answer below. I try to
Note: I'm relatively new to Objective-C and am coming from Java and PHP. Could
I have created a new table including a column note. The default is varchar(255)
Note that the _src inherit IQueryable<U> and V inherit new() ; I wrote the
I have this: _launcherView.pages = [NSArray arrayWithObjects: [NSArray arrayWithObjects: [[[TTLauncherItem alloc] initWithTitle:@New Note image:@bundle://Icon.png
I have an Array and want to insert a new element in between all
I've a TableCell that creates other cells on push. cell.text = @New note; Everything's
It works in IE/FF but not Chrome. html += '<div id = note style

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.