使用DriveApp FileIterator,如何使用大于我可以在有限的处理时间内处理的集合?

时间:2013-05-23 04:11:11

标签: google-apps-script

FileIterator服务中的新DriveApp可让您以非常简化的方式处理文件。

 // Process all files in the user's Drive.
 var files = DriveApp.getFiles();
 while (files.hasNext()) {
   var file = files.next();
   myProcessingFunction(file);  
 }

在显然为“DocsList”的is now deprecated中,get*ForPaging方法允许通过提供用于分页的令牌来检索大型集合。您可以将令牌存储在一个脚本属性中,并使用它在以后的调用中从正确的位置开始。

您如何在DriveApp中执行此操作?如何处理在有限的处理时间内无法迭代所需文件的情况?

2 个答案:

答案 0 :(得分:0)

以下是跟踪此特定请求的增强请求 - https://code.google.com/p/google-apps-script-issues/issues/detail?id=2834

请将您的详细信息/用例添加到此处,然后按照此处进行进一步更新。

答案 1 :(得分:-1)

我将努力分成两部分:

A) collect files and put them in a Google spreadsheet
B) iterate on each row of the spreadsheet

如果脚本中途停止,则下次脚本触发时会检查是否仍有工作需要在电子表格中完成。