Google应用脚本:搜索文件夹中的所有文档

问题描述 投票:1回答:1

您可以使用GAS在文件夹中的所有文档中搜索字符串,然后返回找到的文档列表?给我一个提示怎么做?

谢谢

raffaele

google-apps-script google-drive-api
1个回答
1
投票

全部在documentation中进行了描述,还请阅读有关搜索参数described here的详细信息。

他们也给出了一个例子,下面有一个您的要求的例子:

    function testSearch(){
    // Log the name of every file that contains a certain string
    // you can get the folder of your choice here by its ID or by its name, in the second case the returned object is a folder iterator so you will have to iterate its content. There are examples all around on how to do that.
      var files = DriveApp.getRootFolder().searchFiles( 
      'fullText contains "example"');
        while (files.hasNext()) {
          var file = files.next();
          Logger.log(file.getName());
      }
    }
© www.soinside.com 2019 - 2024. All rights reserved.