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

Searches Drive files using a query string.

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

Better Sheets tutorials

Every Google Drive File Created in Last 24 Hours

Every Google Drive File Created in Last 24 Hours

Create a simple report in a Google Sheet that documents every file in yo...
Get Every Editor on Every Google File I Own

Get Every Editor on Every Google File I Own

Get every editor if you're looking for the sheets and documents you've s...

Related blog posts

Written guides about DriveApp.searchFiles().

Browse the blog