Returns the top-level My Drive folder.
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
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
-
.getFolderById()
Loads a Drive folder by its folder ID.
-
.createFolder()
Creates a new folder in Drive.
-
.getFoldersByName()
Finds folders in Drive that match a given name.
-
.getUrl()
Returns the web link to open a file or folder.
-
.getFilesByName()
Finds files in Drive that match a given name.
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.getRootFolder().