Reputation: 49
Can you search for a string in all documents in a folder with GAS and return the list of found documents? give me a hint of how to do so.
Upvotes: 1
Views: 10446
Reputation: 46794
This is all described in the documentation , read also the details about search arguments described here.
They give an example too, below it an example with your requirements :
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());
}
}
Upvotes: 1