用于搜索的 Google 驱动器脚本 - 我无法添加搜索词的变量。一旦我添加它,我就会继续收到错误 - 也许我做错了?
最终我想要一个带有搜索框和搜索术语的按钮的网络应用程序。随着所有者变量...
function SearchFiles() {
//Please enter your search term in the place of Letter
var searchterm ='print';
var searchFor ='title contains "searchterm"';
var owneris ='and "youremail@yourdomain.com" 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]);
}
}
最佳答案
您只需在正确的位置添加引号即可:
var searchterm ="'print';
var searchFor ="title contains " + searchterm;
var owneris =" and 'youremail@yourdomain.com' in owners";
请务必更改您的 mail@yourdomain.com
关于javascript - Google 脚本应用程序-变量内的变量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41641556/