class DriveApp method .getRootFolder()

DriveApp is the Apps Script service.

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

What it does

Returns the top-level My Drive folder.

Why it's used

  • Start browsing from My Drive when you do not have a folder ID.
  • Build folder pickers or backup scripts from the top level.

Common errors

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

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

Browse the blog