AI-generated Key Takeaways
- 
          The Drive service in Apps Script allows scripts to manage files and folders in Google Drive. 
- 
          For enhanced features, including shared drive access, use the advanced Drive service. 
- 
          If using a standard Cloud project, the Drive API must be manually enabled. 
- 
          Google Workspace Administrators can disable the Drive SDK, affecting script access unless the add-on is domain-wide installed or the client is allowlisted. 
This service lets scripts create, find, and modify files and folders in Google Drive. Although the built-in Drive service is easier to use, it has some limitations. For the most up-to-date features and support, and to access files or folders in shared drives, use the advanced Drive service.
If your script uses a standard Cloud project instead of a default Cloud project, you must manually turn on the Drive API. In your standard Cloud project, turn on the Drive API:
The following code sample shows how to log the names of each file in the user's My Drive folder:// Logs the name of every file in the user's Drive.
var files = DriveApp.getFiles();
while (files.hasNext()) {
  var file = files.next();
  console.log(file.getName());
}Classes
| Name | Brief description | 
|---|---|
| Access | An enum representing classes of users who can access a file or folder, besides any individual users who have been explicitly given access. | 
| Drive | Allows scripts to create, find, and modify files and folders in Google Drive. | 
| File | A file in Google Drive. | 
| File | An iterator that allows scripts to iterate over a potentially large collection of files. | 
| Folder | A folder in Google Drive. | 
| Folder | An object that allows scripts to iterate over a potentially large collection of folders. | 
| Permission | An enum representing the permissions granted to users who can access a file or folder, besides any individual users who have been explicitly given access. | 
| User | A user associated with a file in Google Drive. | 
Access
Properties
| Property | Type | Description | 
|---|---|---|
| ANYONE | Enum | Anyone on the Internet can find and access. | 
| ANYONE_WITH_LINK | Enum | Anyone who has the link can access. | 
| DOMAIN | Enum | People in your domain can find and access. | 
| DOMAIN_WITH_LINK | Enum | People in your domain who have the link can access. | 
| PRIVATE | Enum | Only people explicitly granted permission can access. | 
DriveApp 
Properties
| Property | Type | Description | 
|---|---|---|
| Access | Access | An enum representing classes of users who can access a file or folder, besides any individual users who have been explicitly given access. | 
| Permission | Permission | An enum representing the permissions granted to users who can access a file or folder, besides any individual users who have been explicitly given access. | 
Methods
| Method | Return type | Brief description | 
|---|---|---|
| continue | File | Resumes a file iteration using a continuation token from a previous iterator. | 
| continue | Folder | Resumes a folder iteration using a continuation token from a previous iterator. | 
| create | File | Creates a file in the root of the user's Drive from a given Blobof arbitrary data. | 
| create | File | Creates a text file in the root of the user's Drive with the given name and contents. | 
| create | File | Creates a file in the root of the user's Drive with the given name, contents, and MIME type. | 
| create | Folder | Creates a folder in the root of the user's Drive with the given name. | 
| create | File | Creates a shortcut to the provided Drive item ID, and returns it. | 
| create | File | Creates a shortcut to the provided Drive item ID and resource key, and returns it. | 
| enforce | void | Enables or disables enforceSingleParent behavior for all calls affecting item parents. | 
| get | File | Gets the file with the given ID. | 
| get | File | Gets the file with the given ID and resource key. | 
| get | File | Gets a collection of all files in the user's Drive. | 
| get | File | Gets a collection of all files in the user's Drive that have the given name. | 
| get | File | Gets a collection of all files in the user's Drive that have the given MIME type. | 
| get | Folder | Gets the folder with the given ID. | 
| get | Folder | Gets the folder with the given ID and resource key. | 
| get | Folder | Gets a collection of all folders in the user's Drive. | 
| get | Folder | Gets a collection of all folders in the user's Drive that have the given name. | 
| get | Folder | Gets the folder at the root of the user's Drive. | 
| get | Integer | Gets the number of bytes the user is allowed to store in Drive. | 
| get | Integer | Gets the number of bytes the user is currently storing in Drive. | 
| get | File | Gets a collection of all the files in the trash of the user's Drive. | 
| get | Folder | Gets a collection of all the folders in the trash of the user's Drive. | 
| search | File | Gets a collection of all files in the user's Drive that match the given search criteria. | 
| search | Folder | Gets a collection of all folders in the user's Drive that match the given search criteria. | 
File
Methods
| Method | Return type | Brief description | 
|---|---|---|
| add | File | Add the given user to the list of commenters for the File. | 
| add | File | Add the given user to the list of commenters for the File. | 
| add | File | Add the given array of users to the list of commenters for the File. | 
| add | File | Adds the given user to the list of editors for the File. | 
| add | File | Adds the given user to the list of editors for the File. | 
| add | File | Adds the given array of users to the list of editors for the File. | 
| add | File | Adds the given user to the list of viewers for the File. | 
| add | File | Adds the given user to the list of viewers for the File. | 
| add | File | Adds the given array of users to the list of viewers for the File. | 
| get | Permission | Gets the permission granted to a specific user. | 
| get | Permission | Gets the permission granted to a specific user. | 
| get | Blob | Return the data inside this object as a blob converted to the specified content type. | 
| get | Blob | Return the data inside this object as a blob. | 
| get | Date | Gets the date the Filewas created. | 
| get | String | Gets the description for the File. | 
| get | String | Gets the URL that can be used to download the file. | 
| get | User[] | Gets the list of editors for this File. | 
| get | String | Gets the ID of the File. | 
| get | Date | Gets the date the Filewas last updated. | 
| get | String | Gets the MIME type of the file. | 
| get | String | Gets the name of the File. | 
| get | User | Gets the file owner. | 
| get | Folder | Gets a collection of folders that are immediate parents of the File. | 
| get | String | Gets the resource key of the Filethat is required to access items that
have been shared using a link. | 
| get | Boolean | Gets whether this Fileis eligible to apply the security update that
requires a resource key for access when it's shared using a link. | 
| get | Boolean | Gets whether this Filerequires a resource key for access when it's
shared using a link. | 
| get | Access | Gets which class of users can access the File, besides any individual
users who have been explicitly given access. | 
| get | Permission | Gets the permission granted to those users who can access the File,
besides any individual users who have been explicitly given access. | 
| get | Integer | Gets the number of bytes used to store the Filein Drive. | 
| get | String | If this is a Shortcut, returns the ID of the item it points to. | 
| get | String | If this is a Shortcut, returns the mime type of the item it points to. | 
| get | String | If the file is a shortcut, returns the resource key of the item it points to. | 
| get | Blob | Gets a thumbnail image for the file, or nullif no thumbnail exists. | 
| get | String | Gets the URL that can be used to open the Filein a Google App like
Drive or Docs. | 
| get | User[] | Gets the list of viewers and commenters for this File. | 
| is | Boolean | Determines whether users with edit permissions to the Fileare allowed to
share with other users or change the permissions. | 
| is | Boolean | Determines whether the Filehas been starred in the user's Drive. | 
| is | Boolean | Determines whether the Fileis in the trash of the user's Drive. | 
| make | File | Creates a copy of the file. | 
| make | File | Creates a copy of the file in the destination directory. | 
| make | File | Creates a copy of the file and names it with the name provided. | 
| make | File | Creates a copy of the file in the destination directory and names it with the name provided. | 
| move | File | Moves this item to the provided destination folder. | 
| remove | File | Removes the given user from the list of commenters for the File. | 
| remove | File | Removes the given user from the list of commenters for the File. | 
| remove | File | Removes the given user from the list of editors for the File. | 
| remove | File | Removes the given user from the list of editors for the File. | 
| remove | File | Removes the given user from the list of viewers and commenters for the File. | 
| remove | File | Removes the given user from the list of viewers and commenters for the File. | 
| revoke | File | Revokes the access to the Filegranted to the given user. | 
| revoke | File | Revokes the access to the Filegranted to the given user. | 
| set | File | Overwrites the content of the file with a given replacement. | 
| set | File | Sets the description for the File. | 
| set | File | Sets the name of the File. | 
| set | File | Changes the owner of the File. | 
| set | File | Changes the owner of the File. | 
| set | File | Sets whether the Filerequires a resource key for access when it's
shared using a link. | 
| set | File | Sets whether users with edit permissions to the Fileare allowed to share
with other users or change the permissions. | 
| set | File | Sets which class of users can access the Fileand what permissions
those users are granted, besides any individual users who have been explicitly given access. | 
| set | File | Sets whether the Fileis starred in the user's Drive. | 
| set | File | Sets whether the Fileis in the trash of the user's Drive. | 
FileIterator 
Methods
| Method | Return type | Brief description | 
|---|---|---|
| get | String | Gets a token that can be used to resume this iteration at a later time. | 
| has | Boolean | Determines whether calling next()will return an item. | 
| next() | File | Gets the next item in the collection of files or folders. | 
Folder
Methods
| Method | Return type | Brief description | 
|---|---|---|
| add | Folder | Adds the given user to the list of editors for the Folder. | 
| add | Folder | Adds the given user to the list of editors for the Folder. | 
| add | Folder | Adds the given array of users to the list of editors for the Folder. | 
| add | Folder | Adds the given user to the list of viewers for the Folder. | 
| add | Folder | Adds the given user to the list of viewers for the Folder. | 
| add | Folder | Adds the given array of users to the list of viewers for the Folder. | 
| create | File | Creates a file in the current folder from a given Blobof arbitrary data. | 
| create | File | Creates a text file in the current folder with the given name and contents. | 
| create | File | Creates a file in the current folder with the given name, contents, and MIME type. | 
| create | Folder | Creates a folder in the current folder with the given name. | 
| create | File | Creates a shortcut to the provided Drive item ID, and returns it. | 
| create | File | Creates a shortcut to the provided Drive item ID and resource key, and returns it. | 
| get | Permission | Gets the permission granted to a specific user. | 
| get | Permission | Gets the permission granted to a specific user. | 
| get | Date | Gets the date the Folderwas created. | 
| get | String | Gets the description for the Folder. | 
| get | User[] | Gets the list of editors for this Folder. | 
| get | File | Gets a collection of all files that are children of the current folder. | 
| get | File | Gets a collection of all files that are children of the current folder and have the given name. | 
| get | File | Gets a collection of all files that are children of the current folder and have the given MIME type. | 
| get | Folder | Gets a collection of all folders that are children of the current folder. | 
| get | Folder | Gets a collection of all folders that are children of the current folder and have the given name. | 
| get | String | Gets the ID of the Folder. | 
| get | Date | Gets the date the Folderwas last updated. | 
| get | String | Gets the name of the Folder. | 
| get | User | Gets the owner of this Folder. | 
| get | Folder | Gets a collection of folders that are immediate parents of the Folder. | 
| get | String | Gets the resource key of the Folderthat is required to access items that
have been shared using a link. | 
| get | Boolean | Gets whether this Folderis eligible to apply the security update that
requires a resource key for access when it's shared using a link. | 
| get | Boolean | Gets whether this Folderrequires a resource key for access when it's
shared using a link. | 
| get | Access | Gets which class of users can access the Folder, besides any individual
users who have been explicitly given access. | 
| get | Permission | Gets the permission granted to those users who can access the Folder,
besides any individual users who have been explicitly given access. | 
| get | Integer | Gets the number of bytes used to store the Folderin Drive. | 
| get | String | Gets the URL that can be used to open the Folderin a Google App like
Drive or Docs. | 
| get | User[] | Gets the list of viewers and commenters for this Folder. | 
| is | Boolean | Determines whether users with edit permissions to the Folderare allowed to
share with other users or change the permissions. | 
| is | Boolean | Determines whether the Folderhas been starred in the user's Drive. | 
| is | Boolean | Determines whether the Folderis in the trash of the user's Drive. | 
| move | Folder | Moves this item to the provided destination folder. | 
| remove | Folder | Removes the given user from the list of editors for the Folder. | 
| remove | Folder | Removes the given user from the list of editors for the Folder. | 
| remove | Folder | Removes the given user from the list of viewers and commenters for the Folder. | 
| remove | Folder | Removes the given user from the list of viewers and commenters for the Folder. | 
| revoke | Folder | Revokes the access to the Foldergranted to the given user. | 
| revoke | Folder | Revokes the access to the Foldergranted to the given user. | 
| search | File | Gets a collection of all files that are children of the current folder and match the given search criteria. | 
| search | Folder | Gets a collection of all folders that are children of the current folder and match the given search criteria. | 
| set | Folder | Sets the description for the Folder. | 
| set | Folder | Sets the name of the Folder. | 
| set | Folder | Changes the owner of the Folder. | 
| set | Folder | Changes the owner of the Folder. | 
| set | Folder | Sets whether the Folderrequires a resource key for access when it's
shared using a link. | 
| set | Folder | Sets whether users with edit permissions to the Folderare allowed to share
with other users or change the permissions. | 
| set | Folder | Sets which class of users can access the Folderand what permissions
those users are granted, besides any individual users who have been explicitly given access. | 
| set | Folder | Sets whether the Folderis starred in the user's Drive. | 
| set | Folder | Sets whether the Folderis in the trash of the user's Drive. | 
FolderIterator 
Methods
| Method | Return type | Brief description | 
|---|---|---|
| get | String | Gets a token that can be used to resume this iteration at a later time. | 
| has | Boolean | Determines whether calling next()will return an item. | 
| next() | Folder | Gets the next item in the collection of files or folders. | 
Permission
Properties
| Property | Type | Description | 
|---|---|---|
| VIEW | Enum | Users who can access the file or folder are able only to view it or copy it. | 
| EDIT | Enum | Users who can access the file or folder are able to edit it. | 
| COMMENT | Enum | Users who can access the file or folder are able only to view it, copy it, or comment on it. | 
| OWNER | Enum | The user owns the file or folder. | 
| ORGANIZER | Enum | Users who can organize files and folders within a shared drive. | 
| FILE_ORGANIZER | Enum | Users who can edit, trash, and move content within a shared drive. | 
| NONE | Enum | The user does not have any permissions for the file or folder. | 
User
Methods
| Method | Return type | Brief description | 
|---|---|---|
| get | String | Gets the domain name associated with the user's account. | 
| get | String | Gets the user's email address. | 
| get | String | Gets the user's name. | 
| get | String | Gets the URL for the user's photo. |