0

Google drive script for searching- I can't add the variable for searchterm. As soon as I add it I continue to get errors - Perhaps I am going about it wrong?

Ultimately I would like a web app with a searchbox, button that searches for the terms. With the owneris variable...

function SearchFiles() {
//Please enter your search term in the place of Letter
var searchterm ='print';
var searchFor ='title contains "searchterm"';
var owneris ='and "[email protected]" in Owners';
var names =[];
var fileIds=[];
var files = DriveApp.searchFiles(searchFor + owneris);
while (files.hasNext()) {
  var file = files.next();
  var fileId = file.getId();// To get FileId of the file
 fileIds.push(fileId);
 var name = file.getName();
 names.push(name);

}

for (var i=0;i<names.length;i++){
 Logger.log(names[i]);
Logger.log("https://drive.google.com/uc?export=download&id=" + fileIds[i]);

}

}

1 Answer 1

2

You just need to add quotes in the right places and it should work:

var searchterm ="'print';
var searchFor ="title contains " + searchterm;
var owneris =" and '[email protected]' in owners";

Be sure to change [email protected]

Sign up to request clarification or add additional context in comments.

1 Comment

Great!it worked! Thanks for you help! Now I have to figure out how to get an input text box in google html to populate the searchterm variable. I may need to ask for more help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.