How to properly use Google App Script "not" query operator for searchFolders() function

I am trying to to search through a shared drive for KPI reports that do not contain "Archived" in the name. But Im getting "Invalid argument: q" error

I have tried using "not title contains 'Archived'" and "title not contains 'Archived'"

var clientFolder = DriveApp.searchFiles("title contains 'KPI Report' and mimeType = 'application/vnd.google-apps.spreadsheet' and modifiedDate >= '" + dateModified + "' not title contains 'Archived'");

1 answer

  • answered 2019-09-11 19:27 MirrorForged

    Simply had to put "and" before "not title"! Credit to @Chris G.!

    var clientFolder = DriveApp.searchFiles("title contains 'KPI Report' and mimeType = 'application/vnd.google-apps.spreadsheet' and modifiedDate >= '" + dateModified + "' and not title contains 'Archived'");