Last active
December 16, 2020 04:47
-
-
Save bytrangle/ea733479b33609a490bead421c2efb40 to your computer and use it in GitHub Desktop.
Search Files in Google Drive Whose Names Matches a Given Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Example: Search for all files in Google Drive whose file names contains the word 'tracker'. The result would be: | |
- Fitness tracker | |
- Personal finance tracker | |
- Job application tracker | |
*/ | |
function searchFiles(name) { | |
var results = []; | |
var query = `title contains "${name}"`; | |
var files = DriveApp.searchFiles(query); | |
while (files.hasNext()) { | |
var file = files.next(); | |
results.push(file); | |
Logger.log([file.getDateCreated(), file.getName(), file.getUrl(), file.getMimeType()].join()); | |
} | |
return results | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment