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.
Snippets using this method
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
Every Google Drive File Created in Last 24 Hours
Get Every Editor on Every Google File I Own
Related blog posts
Written guides about DriveApp.searchFiles().
How I Use Google clasp to Write Apps Script with AI
Google clasp keeps your Apps Script in files on your computer, so an AI like Claude Code can read, edit and push it. My setup, my push script, and what broke.
Read post →Extract URLs from Google Sheets
Extract url from hyperlink google sheets.Skip the Command K. This Google Sheet tutorial will make it easier for you to extract URLS from Google Sheets.
Read post →