Google apps script 从google插件下载多个文件

Google apps script 从google插件下载多个文件,google-apps-script,return,Google Apps Script,Return,嗨,我正试图下载多个文件从谷歌文件夹作为txt。我正在使用谷歌脚本。到目前为止,我的代码将成功地从一个文件夹下载第一个文件,但它停止并不会下载该文件夹中的其余文件。谢谢 function doGet() { var folder = DriveApp.getFolderById('FolderKeyHere') var files = folder.getFiles(); while (files.hasNext()) { var file = files.next();

嗨,我正试图下载多个文件从谷歌文件夹作为txt。我正在使用谷歌脚本。到目前为止,我的代码将成功地从一个文件夹下载第一个文件,但它停止并不会下载该文件夹中的其余文件。谢谢

function doGet() {


var folder = DriveApp.getFolderById('FolderKeyHere')

var files = folder.getFiles();
   while (files.hasNext()) {
      var file = files.next();
      Logger.log(file.getName());
      var id = file.getId(); 

     var doc = DocumentApp.openById(id);

     var string = doc.getBody().getText();

     var output = ContentService.createTextOutput();
     output.setMimeType(ContentService.MimeType.TEXT);
     output.setContent(string);
     output.downloadAsFile(file.getName());

     return output;

   };

};

这不可能像那样,
返回输出
将实际“返回”应用程序,当然会退出while循环

我认为如果没有用户操作,您将无法循环这种过程

您可能会构建一个小Ui,在每次单击按钮时都会有一个按钮来逐个下载文件,但我想这不是您想要的

为什么不在驱动器中创建所有文件,将所有文件压缩到一个zip文件中,下载zip文件,然后从驱动器中删除这些文件和zip文件


编写时间稍长,但我认为这是在一次下载中获取多个文件的唯一可用工作流

我试着下载一个zip文件,但它只能下载为.docx文件,而我希望所有文件都是.txt文件。是否可以存储多个output.downloadfile文件,然后返回它们的倍数?