Google apps script 谷歌应用程序脚本:搜索文件夹中的所有文档

Google apps script 谷歌应用程序脚本:搜索文件夹中的所有文档,google-apps-script,google-drive-api,Google Apps Script,Google Drive Api,您可以使用GAS在文件夹中的所有文档中搜索字符串,并返回找到的文档列表?告诉我怎么做 谢谢 raffaele中介绍了所有这些,请阅读有关搜索参数的详细信息 他们也给出了一个示例,下面是您的需求示例: function testSearch(){ // Log the name of every file that contains a certain string // you can get the folder of your choice here by its I

您可以使用GAS在文件夹中的所有文档中搜索字符串,并返回找到的文档列表?告诉我怎么做

谢谢


raffaele

中介绍了所有这些,请阅读有关搜索参数的详细信息

他们也给出了一个示例,下面是您的需求示例:

    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());
      }
    }

非常感谢您的回复和及时回复。我不是程序员,但我真的很喜欢谷歌应用程序脚本。研究并尝试创建一个web应用程序。再次感谢。Serge我理解操作,但无法查看子文件夹的文件。你有主意吗?代码://work fine ONE LIVEL FOLDER var search=''dfdgffdzyy1mzjuyyjq5mgy3mze'位于父文件夹';//包含文件的文件夹//不工作var search='“dfffggfdgTkhhQ4543saddsd5MGY3MzE”位于父文件夹“;//文件夹及其子文件夹及其文件var files=DriveApp.searchFiles(搜索);while(files.hasNext()){var file=files.next();Logger.log(file.getName());}