class DriveApp method .getFilesByName()

DriveApp is the Apps Script service.

.getFilesByName() is the method name you will see after a dot in your code.

What it does

Finds files in Drive that match a given name.

Why it's used

  • Find Invoice Template.pdf without asking the user to browse.
  • Grab the latest file when everyone uses the same name.

Common errors

  • Forgetting parentheses on getFilesByName. Write DriveApp.getFilesByName(), not DriveApp.getFilesByName or getFilesByName by itself.
  • Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).getFilesByName().
  • Adding spaces where they do not belong. Write DriveApp.getFilesByName(), not DriveApp .getFilesByName(), DriveApp.getFilesByName (), or DriveApp . getFilesByName().
  • Wrong capitalization. Use DriveApp and getFilesByName, not driveapp or getfilesbyname.

Explore

Related methods

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.getFilesByName().

Browse the blog