您可以使用GAS在文件夹中的所有文档中搜索字符串并返回找到的文档列表吗?给我一个如何做的提示?
谢谢
拉菲尔
答案 0 :(得分: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());
}
}