Loads a Drive folder by its folder ID.
class DriveApp method .getFolderById()
DriveApp is the Apps Script service.
.getFolderById() is the method name you will see after a dot in your code.
What it does
Why it's used
- Drop exports into a shared team folder by ID.
- List or clean up files inside a specific client folder.
Common errors
- Forgetting parentheses on getFolderById. Write DriveApp.getFolderById(), not DriveApp.getFolderById or getFolderById by itself.
- Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).getFolderById().
- Adding spaces where they do not belong. Write DriveApp.getFolderById(), not DriveApp .getFolderById(), DriveApp.getFolderById (), or DriveApp . getFolderById().
- Wrong capitalization. Use DriveApp and getFolderById, not driveapp or getfolderbyid.
1 Snippets using this method
Explore
Related methods
-
.getFileById()
Loads a Drive file by its file ID.
-
.getFoldersByName()
Finds folders in Drive that match a given name.
-
.createFolder()
Creates a new folder in Drive.
-
.getRootFolder()
Returns the top-level My Drive folder.
-
.getFilesByName()
Finds files in Drive that match a given name.
More Apps Script
1 Better Sheets tutorials
Automatic Weekly Backup of Google Sheets
Related blog posts
Written guides about DriveApp.getFolderById().