Searches Drive files using a query string.
class DriveApp method .searchFiles()
DriveApp is the Apps Script service.
.searchFiles() is the method name you will see after a dot in your code.
What it does
Why it's used
- Find all spreadsheets modified this week or owned by a teammate.
- Power admin tools that audit Drive from a sheet.
Common errors
- Forgetting parentheses on searchFiles. Write DriveApp.searchFiles(), not DriveApp.searchFiles or searchFiles by itself.
- Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).searchFiles().
- Adding spaces where they do not belong. Write DriveApp.searchFiles(), not DriveApp .searchFiles(), DriveApp.searchFiles (), or DriveApp . searchFiles().
- Wrong capitalization. Use DriveApp and searchFiles, not driveapp or searchfiles.
Explore
Related methods
-
.getFilesByName()
Finds files in Drive that match a given name.
-
.getFoldersByName()
Finds folders in Drive that match a given name.
-
.getFileById()
Loads a Drive file by its file ID.
-
.getFolderById()
Loads a Drive folder by its folder ID.
-
.addFile()
Moves a file into a folder.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about DriveApp.searchFiles().