Reputation: 158
I'm trying to write a script that takes the name of a file from a spreadsheet, searches my drive for that file, and returns the Id of that file.
I think it doesn't like my query string, but I'm not sure what's wrong with it.
function SearchDriveFiles (){
var moduleName =
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet.getRange("F19").getValue();
var searchFor = 'title contains"'+moduleName+'"';
var names =[];
var fileIds=[];
var files = DriveApp.searchFiles(searchFor);
//iterates through files
while (files.hasNext()) { //This is where the error happens
var file = files.next();
var fileId = file.getId();
fileIds.push(fileId);
var name = file.getName();
names.push(name);}
Logger.log(fileIds);
Logger.log(names);
}
I want to log the file name and Id, but every time I run the function I get "Invalid argument: q"
Upvotes: 3
Views: 979
Reputation: 201428
How about this modification?
var searchFor = 'title contains"'+moduleName+'"';
var searchFor = 'title contains "'+moduleName+'"';
title
.contains
.If this didn't resolve your issue, I apologize.
Upvotes: 5