Folder

A folder in Google Drive. Folders can be accessed or created from `https://developers.google.com/apps-script/reference/drive/drive-app`.

```javascript
// Log the name of every folder in the user's Drive.
const folders = DriveApp.getFolders();
while (folders.hasNext()) {
  const folder = folders.next();
  Logger.log(folder.getName());
}
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/drive/folder#addEditor(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given user to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#addEditor(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given user to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#addEditors(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given array of users to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#addViewer(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given user to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#addViewer(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given user to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#addViewers(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given array of users to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#createFile(BlobSource)` | `https://developers.google.com/apps-script/reference/drive/file` | Creates a file in the current folder from a given `Blob` of arbitrary data. |
| `https://developers.google.com/apps-script/reference/drive/folder#createFile(String,String)` | `https://developers.google.com/apps-script/reference/drive/file` | Creates a text file in the current folder with the given name and contents. |
| `https://developers.google.com/apps-script/reference/drive/folder#createFile(String,String,String)` | `https://developers.google.com/apps-script/reference/drive/file` | Creates a file in the current folder with the given name, contents, and MIME type. |
| `https://developers.google.com/apps-script/reference/drive/folder#createFolder(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Creates a folder in the current folder with the given name. |
| `https://developers.google.com/apps-script/reference/drive/folder#createShortcut(String)` | `https://developers.google.com/apps-script/reference/drive/file` | Creates a shortcut to the provided Drive item ID, and returns it. |
| `https://developers.google.com/apps-script/reference/drive/folder#createShortcutForTargetIdAndResourceKey(String,String)` | `https://developers.google.com/apps-script/reference/drive/file` | Creates a shortcut to the provided Drive item ID and resource key, and returns it. |
| `https://developers.google.com/apps-script/reference/drive/folder#getAccess(String)` | `https://developers.google.com/apps-script/reference/drive/permission` | Gets the permission granted to a specific user. |
| `https://developers.google.com/apps-script/reference/drive/folder#getAccess(User)` | `https://developers.google.com/apps-script/reference/drive/permission` | Gets the permission granted to a specific user. |
| `https://developers.google.com/apps-script/reference/drive/folder#getDateCreated()` | `Date` | Gets the date the `https://developers.google.com/apps-script/reference/drive/folder#` was created. |
| `https://developers.google.com/apps-script/reference/drive/folder#getDescription()` | `String` | Gets the description for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getEditors()` | `https://developers.google.com/apps-script/reference/drive/user` | Gets the list of editors for this `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getFiles()` | `https://developers.google.com/apps-script/reference/drive/file-iterator` | Gets a collection of all files that are children of the current folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#getFilesByName(String)` | `https://developers.google.com/apps-script/reference/drive/file-iterator` | Gets a collection of all files that are children of the current folder and have the given name. |
| `https://developers.google.com/apps-script/reference/drive/folder#getFilesByType(String)` | `https://developers.google.com/apps-script/reference/drive/file-iterator` | Gets a collection of all files that are children of the current folder and have the given MIME type. |
| `https://developers.google.com/apps-script/reference/drive/folder#getFolders()` | `https://developers.google.com/apps-script/reference/drive/folder-iterator` | Gets a collection of all folders that are children of the current folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#getFoldersByName(String)` | `https://developers.google.com/apps-script/reference/drive/folder-iterator` | Gets a collection of all folders that are children of the current folder and have the given name. |
| `https://developers.google.com/apps-script/reference/drive/folder#getId()` | `String` | Gets the ID of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getLastUpdated()` | `Date` | Gets the date the `https://developers.google.com/apps-script/reference/drive/folder#` was last updated. |
| `https://developers.google.com/apps-script/reference/drive/folder#getName()` | `String` | Gets the name of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getOwner()` | `https://developers.google.com/apps-script/reference/drive/user` | Gets the owner of this `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getParents()` | `https://developers.google.com/apps-script/reference/drive/folder-iterator` | Gets a collection of folders that are immediate parents of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#getResourceKey()` | `String` | Gets the resource key of the `https://developers.google.com/apps-script/reference/drive/folder#` that is required to access items that have been shared using a link. |
| `https://developers.google.com/apps-script/reference/drive/folder#getSecurityUpdateEligible()` | `Boolean` | Gets whether this `https://developers.google.com/apps-script/reference/drive/folder#` is eligible to apply the security update that requires a resource key for access when it's shared using a link. |
| `https://developers.google.com/apps-script/reference/drive/folder#getSecurityUpdateEnabled()` | `Boolean` | Gets whether this `https://developers.google.com/apps-script/reference/drive/folder#` requires a resource key for access when it's shared using a link. |
| `https://developers.google.com/apps-script/reference/drive/folder#getSharingAccess()` | `https://developers.google.com/apps-script/reference/drive/access` | Gets which class of users can access the `https://developers.google.com/apps-script/reference/drive/folder#`, besides any individual users who have been explicitly given access. |
| `https://developers.google.com/apps-script/reference/drive/folder#getSharingPermission()` | `https://developers.google.com/apps-script/reference/drive/permission` | Gets the permission granted to those users who can access the `https://developers.google.com/apps-script/reference/drive/folder#`, besides any individual users who have been explicitly given access. |
| `https://developers.google.com/apps-script/reference/drive/folder#getSize()` | `Integer` | Gets the number of bytes used to store the `https://developers.google.com/apps-script/reference/drive/folder#` in Drive. |
| `https://developers.google.com/apps-script/reference/drive/folder#getUrl()` | `String` | Gets the URL that can be used to open the `https://developers.google.com/apps-script/reference/drive/folder#` in a Google App like Drive or Docs. |
| `https://developers.google.com/apps-script/reference/drive/folder#getViewers()` | `https://developers.google.com/apps-script/reference/drive/user` | Gets the list of viewers and commenters for this `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#isShareableByEditors()` | `Boolean` | Determines whether users with edit permissions to the `https://developers.google.com/apps-script/reference/drive/folder#` are allowed to share with other users or change the permissions. |
| `https://developers.google.com/apps-script/reference/drive/folder#isStarred()` | `Boolean` | Determines whether the `https://developers.google.com/apps-script/reference/drive/folder#` has been starred in the user's Drive. |
| `https://developers.google.com/apps-script/reference/drive/folder#isTrashed()` | `Boolean` | Determines whether the `https://developers.google.com/apps-script/reference/drive/folder#` is in the trash of the user's Drive. |
| `https://developers.google.com/apps-script/reference/drive/folder#moveTo(Folder)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Moves this item to the provided destination folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeEditor(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given user from the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeEditor(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given user from the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeViewer(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given user from the list of viewers and commenters for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeViewer(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given user from the list of viewers and commenters for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#revokePermissions(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Revokes the access to the `https://developers.google.com/apps-script/reference/drive/folder#` granted to the given user. |
| `https://developers.google.com/apps-script/reference/drive/folder#revokePermissions(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Revokes the access to the `https://developers.google.com/apps-script/reference/drive/folder#` granted to the given user. |
| `https://developers.google.com/apps-script/reference/drive/folder#searchFiles(String)` | `https://developers.google.com/apps-script/reference/drive/file-iterator` | Gets a collection of all files that are children of the current folder and match the given search criteria. |
| `https://developers.google.com/apps-script/reference/drive/folder#searchFolders(String)` | `https://developers.google.com/apps-script/reference/drive/folder-iterator` | Gets a collection of all folders that are children of the current folder and match the given search criteria. |
| `https://developers.google.com/apps-script/reference/drive/folder#setDescription(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets the description for the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#setName(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets the name of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#setOwner(String)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Changes the owner of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#setOwner(User)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Changes the owner of the `https://developers.google.com/apps-script/reference/drive/folder#`. |
| `https://developers.google.com/apps-script/reference/drive/folder#setSecurityUpdateEnabled(Boolean)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` requires a resource key for access when it's shared using a link. |
| `https://developers.google.com/apps-script/reference/drive/folder#setShareableByEditors(Boolean)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets whether users with edit permissions to the `https://developers.google.com/apps-script/reference/drive/folder#` are allowed to share with other users or change the permissions. |
| `https://developers.google.com/apps-script/reference/drive/folder#setSharing(Access,Permission)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets which class of users can access the `https://developers.google.com/apps-script/reference/drive/folder#` and what permissions those users are granted, besides any individual users who have been explicitly given access. |
| `https://developers.google.com/apps-script/reference/drive/folder#setStarred(Boolean)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` is starred in the user's Drive. |
| `https://developers.google.com/apps-script/reference/drive/folder#setTrashed(Boolean)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` is in the trash of the user's Drive. |

### Deprecated methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/drive/folder#addFile(File)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given file to the current folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#addFolder(Folder)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Adds the given folder to the current folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeFile(File)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given file from the current folder. |
| `https://developers.google.com/apps-script/reference/drive/folder#removeFolder(Folder)` | `https://developers.google.com/apps-script/reference/drive/folder#` | Removes the given folder from the current folder. |

## Detailed documentation

### `addEditor(emailAddress)`

Adds the given user to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. If the user was already
on the list of viewers, this method promotes the user out of the list of viewers.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addEditor(user)`

Adds the given user to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. If the user was already
on the list of viewers, this method promotes the user out of the list of viewers.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addEditors(emailAddresses)`

Adds the given array of users to the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. If any of the
users were already on the list of viewers, this method promotes them out of the list of
viewers.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddresses` | `String[]` | An array of email addresses of the users to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addViewer(emailAddress)`

Adds the given user to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. If the user was already
on the list of editors, this method has no effect.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addViewer(user)`

Adds the given user to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. If the user was already
on the list of editors, this method has no effect.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addViewers(emailAddresses)`

Adds the given array of users to the list of viewers for the `https://developers.google.com/apps-script/reference/drive/folder#`. If any of the
users were already on the list of editors, this method has no effect for them.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddresses` | `String[]` | An array of email addresses of the users to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createFile(blob)`

Creates a file in the current folder from a given `Blob` of arbitrary data.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `blob` | `https://developers.google.com/apps-script/reference/base/blob-source.html` | The data for the new file. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file` --- The new file.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createFile(name, content)`

Creates a text file in the current folder with the given name and contents. Throws an
exception if `content` is larger than 50 MB.

```javascript
// Create a text file with the content "Hello, world!"
DriveApp.getRootFolder().createFile('New Text File', 'Hello, world!');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name of the new file. |
| `content` | `String` | The content for the new file. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file` --- The new file.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createFile(name, content, mimeType)`

Creates a file in the current folder with the given name, contents, and MIME type. Throws
an exception if `content` is larger than 10MB.

```javascript
// Create an HTML file with the content "Hello, world!"
DriveApp.getRootFolder().createFile('New HTML File', '<b>Hello, world!</b>', MimeType.HTML);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name of the new file. |
| `content` | `String` | The content for the new file. |
| `mimeType` | `String` | The MIME type of the new file. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file` --- The new file.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createFolder(name)`

Creates a folder in the current folder with the given name.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name of the new folder. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- The new folder.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createShortcut(targetId)`

Creates a shortcut to the provided Drive item ID, and returns it.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `targetId` | `String` | The file ID of the target file or folder. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file` --- The new shortcut.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `createShortcutForTargetIdAndResourceKey(targetId, targetResourceKey)`

Creates a shortcut to the provided Drive item ID and resource key, and returns it. A resource
key is an additional parameter that needs to be passed to access the target file or folder that
has been shared using a link.

```javascript
// Creates shortcuts for all folders in the user's drive that have a specific
// name.
// TODO(developer): Replace 'Test-Folder' with a valid folder name in your
// drive.
const folders = DriveApp.getFoldersByName('Test-Folder');

// Iterates through all folders named 'Test-Folder'.
while (folders.hasNext()) {
  const folder = folders.next();

  // Creates a shortcut to the provided Drive item ID and resource key, and
  // returns it.
  DriveApp.createShortcutForTargetIdAndResourceKey(
      folder.getId(),
      folder.getResourceKey(),
  );
}
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `targetId` | `String` | The ID of the target file or folder. |
| `targetResourceKey` | `String` | The resource key of the target file or folder. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file` --- The new shortcut.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getAccess(email)`

Gets the permission granted to a specific user. The method doesn't support returning
permissions for a Google Group or permissions inherited through Google Groups.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `email` | `String` | The email address of the user whose permissions should be checked. Google Groups aren't supported. |

#### Return


`https://developers.google.com/apps-script/reference/drive/permission` --- The permissions granted to the user.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getAccess(user)`

Gets the permission granted to a specific user. The method doesn't support returning
permissions for a Google Group or permissions inherited through Google Groups.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user whose permissions should be checked. |

#### Return


`https://developers.google.com/apps-script/reference/drive/permission` --- The permissions granted to the user.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getDateCreated()`

Gets the date the `https://developers.google.com/apps-script/reference/drive/folder#` was created.

#### Return


`Date` --- the date the `https://developers.google.com/apps-script/reference/drive/folder#` was created

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getDescription()`

Gets the description for the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Return


`String` --- the description for the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getEditors()`

Gets the list of editors for this `https://developers.google.com/apps-script/reference/drive/folder#`. If the user who executes the script
does not have edit access to the `https://developers.google.com/apps-script/reference/drive/folder#`, this method returns an empty array.

```javascript
//  Gets a folder by its ID.
//  TODO(developer): Replace the folder ID with your own.
const folder = DriveApp.getFolderById('1234567890abcdefghijklmnopqrstuvwxyz');

// Gets the list of editors and logs their names to the console.
const editors = folder.getEditors();
for (const editor of editors) {
  console.log(editor.getName());
}
```

#### Return


`https://developers.google.com/apps-script/reference/drive/user` --- The list of editors for this `https://developers.google.com/apps-script/reference/drive/folder#` if the user has edit access or an
empty array otherwise.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getFiles()`

Gets a collection of all files that are children of the current folder.

#### Return


`https://developers.google.com/apps-script/reference/drive/file-iterator` --- A collection of all files that are children of the current folder.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getFilesByName(name)`

Gets a collection of all files that are children of the current folder and have the given name.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name of the files to find. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file-iterator` --- A collection of all files that are children of the current folder and have the given name.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getFilesByType(mimeType)`

Gets a collection of all files that are children of the current folder and have the given MIME type.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `mimeType` | `String` | The MIME type of the files to find. |

#### Return


`https://developers.google.com/apps-script/reference/drive/file-iterator` --- A collection of all files that are children of the current folder and have the given MIME
type.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getFolders()`

Gets a collection of all folders that are children of the current folder.

#### Return


`https://developers.google.com/apps-script/reference/drive/folder-iterator` --- A collection of all folders that are children of the current folder.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getFoldersByName(name)`

Gets a collection of all folders that are children of the current folder and have the given name.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name of the folders to find. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder-iterator` --- A collection of all folders that are children of the current folder and have the given name.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getId()`

Gets the ID of the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Return


`String` --- the ID of the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getLastUpdated()`

Gets the date the `https://developers.google.com/apps-script/reference/drive/folder#` was last updated.

#### Return


`Date` --- the date the `https://developers.google.com/apps-script/reference/drive/folder#` was last updated

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getName()`

Gets the name of the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Return


`String` --- the name of the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getOwner()`

Gets the owner of this `https://developers.google.com/apps-script/reference/drive/folder#`.

```javascript
//  Gets a folder by its ID.
//  TODO(developer): Replace the folder ID with your own.
const folder = DriveApp.getFolderById('1234567890abcdefghijklmnopqrstuvwxyz');

// Gets the owner of the folder and logs the name to the console.
const folderOwner = folder.getOwner();
console.log(folderOwner.getName());
```

#### Return


`https://developers.google.com/apps-script/reference/drive/user` --- The owner of this `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getParents()`

Gets a collection of folders that are immediate parents of the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Return


`https://developers.google.com/apps-script/reference/drive/folder-iterator` --- a collection of folders that are immediate parents of the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getResourceKey()`

Gets the resource key of the `https://developers.google.com/apps-script/reference/drive/folder#` that is required to access items that
have been shared using a link.

#### Return


`String` --- The resource key of the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getSecurityUpdateEligible()`

Gets whether this `https://developers.google.com/apps-script/reference/drive/folder#` is eligible to apply the security update that
requires a resource key for access when it's shared using a link.

Drive requires a resource key to access some files or folders that have been shared using a
link. This change is part of a security update. The update is turned on by default for eligible
files and folders. To turn the resource key requirement on or off for eligible files, use
`setSecurityUpdateEnabled`.

Learn more about the [Security update for Google Drive](https://support.google.com/a/answer/10685032).

#### Return


`Boolean` --- Whether the resource key requirement can be applied for the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getSecurityUpdateEnabled()`

Gets whether this `https://developers.google.com/apps-script/reference/drive/folder#` requires a resource key for access when it's
shared using a link. This requirement is turned on by default for eligible files and folders.
To turn the resource key requirement on or off for eligible files, use `
setSecurityUpdateEnabled`.

Learn more about the [Security update for Google Drive](https://support.google.com/a/answer/10685032).

#### Return


`Boolean` --- Whether the resource key requirement is enabled for this `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getSharingAccess()`

Gets which class of users can access the `https://developers.google.com/apps-script/reference/drive/folder#`, besides any individual
users who have been explicitly given access.

#### Return


`https://developers.google.com/apps-script/reference/drive/access` --- which class of users can access the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getSharingPermission()`

Gets the permission granted to those users who can access the `https://developers.google.com/apps-script/reference/drive/folder#`,
besides any individual users who have been explicitly given access.

#### Return


`https://developers.google.com/apps-script/reference/drive/permission` --- the permissions granted to users who can access the `https://developers.google.com/apps-script/reference/drive/folder#`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getSize()`

Gets the number of bytes used to store the `https://developers.google.com/apps-script/reference/drive/folder#` in Drive. Note that
Google Workspace application files do not count toward Drive storage limits and thus return
`0` bytes.

#### Return


`Integer` --- the number of bytes used to store the `https://developers.google.com/apps-script/reference/drive/folder#` in Drive

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getUrl()`

Gets the URL that can be used to open the `https://developers.google.com/apps-script/reference/drive/folder#` in a Google App like
Drive or Docs.

#### Return


`String` --- the URL that can be used to view this `https://developers.google.com/apps-script/reference/drive/folder#` in a Google App like
Drive or Docs

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `getViewers()`

Gets the list of viewers and commenters for this `https://developers.google.com/apps-script/reference/drive/folder#`. If the user who
executes the script does not have edit access to the `https://developers.google.com/apps-script/reference/drive/folder#`, this method
returns an empty array.

```javascript
//  Gets a folder by its ID.
//  TODO(developer): Replace the folder ID with your own.
const folder = DriveApp.getFolderById('1234567890abcdefghijklmnopqrstuvwxyz');

// Gets the list of viewers and logs their names to the console.
const viewers = folder.getViewers();
for (const viewer of viewers) {
  console.log(viewer.getName());
}
```

#### Return


`https://developers.google.com/apps-script/reference/drive/user` --- The list of viewers and commenters for this `https://developers.google.com/apps-script/reference/drive/folder#` if the user has edit
access or an empty array otherwise.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `isShareableByEditors()`

Determines whether users with edit permissions to the `https://developers.google.com/apps-script/reference/drive/folder#` are allowed to
share with other users or change the permissions.

#### Return


`Boolean` --- `true` if users with edit permissions are allowed to share with other users or
change the permissions; `false` if not.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `isStarred()`

Determines whether the `https://developers.google.com/apps-script/reference/drive/folder#` has been starred in the user's Drive.

#### Return


`Boolean` --- `true` if the `https://developers.google.com/apps-script/reference/drive/folder#` is starred in the user's Drive; `false` if not

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `isTrashed()`

Determines whether the `https://developers.google.com/apps-script/reference/drive/folder#` is in the trash of the user's Drive.

#### Return


`Boolean` --- `true` if the `https://developers.google.com/apps-script/reference/drive/folder#` is in the trash of the user's Drive;
`false` if not

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `moveTo(destination)`

Moves this item to the provided destination folder.

The current user must be the owner of the file or have at least edit access to the item's
current parent folder in order to move the item to the destination folder.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `destination` | `https://developers.google.com/apps-script/reference/drive/folder#` | The folder that becomes the new parent. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeEditor(emailAddress)`

Removes the given user from the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. This method doesn't
block users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who have
general access---for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's entire
domain, or if the `https://developers.google.com/apps-script/reference/drive/folder#` is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of viewers.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeEditor(user)`

Removes the given user from the list of editors for the `https://developers.google.com/apps-script/reference/drive/folder#`. This method doesn't
block users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who have
general access---for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's entire
domain, or if the `https://developers.google.com/apps-script/reference/drive/folder#` is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of viewers.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeViewer(emailAddress)`

Removes the given user from the list of viewers and commenters for the `https://developers.google.com/apps-script/reference/drive/folder#`. This
method has no effect if the user is an editor, not a viewer or commenter. This method also
doesn't block users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who
have general access---for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's
entire domain, or if the `https://developers.google.com/apps-script/reference/drive/folder#` is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of editors.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#` for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeViewer(user)`

Removes the given user from the list of viewers and commenters for the `https://developers.google.com/apps-script/reference/drive/folder#`. This
method has no effect if the user is an editor, not a viewer. This method also doesn't block
users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who have general
access---for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's entire domain, or
if the `https://developers.google.com/apps-script/reference/drive/folder#` is in a shared drive that the user can access.

For Drive files, this also removes the user from the list of editors.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#` for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `revokePermissions(emailAddress)`

Revokes the access to the `https://developers.google.com/apps-script/reference/drive/folder#` granted to the given user. This method doesn't
block users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who
have general access --- for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's
entire domain.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user whose access should be revoked. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `revokePermissions(user)`

Revokes the access to the `https://developers.google.com/apps-script/reference/drive/folder#` granted to the given user. This method doesn't
block users from accessing the `https://developers.google.com/apps-script/reference/drive/folder#` if they belong to a class of users who
have general access --- for example, if the `https://developers.google.com/apps-script/reference/drive/folder#` is shared with the user's
entire domain.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user whose access should be revoked. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `searchFiles(params)`

Gets a collection of all files that are children of the current folder and match the given search
criteria. The search criteria are detailed in the [Google Drive SDK documentation](https://developers.google.com/drive/api/v2/ref-search-terms). Note that the Drive
service uses v2 of the Drive API and some query fields differ from v3. Review the [field
differences between v2 and v3](https://developers.google.com/drive/api/guides/v2-to-v3-reference#resource_field_differences_between_v2_and_v3).

The `params` argument is a query string that can contain string values, so take care
to escape quotation marks correctly (for example `"title contains 'Gulliver\\'s
Travels'"` or `'title contains "Gulliver\'s Travels"'`).

```javascript
// Logs the name of every file that are children of the current folder and modified after February 28,
// 2022 whose name contains "untitled.""
const files = DriveApp.getRootFolder().searchFiles(
    'modifiedDate > "2022-02-28" and title contains "untitled"');
while (files.hasNext()) {
  const file = files.next();
  console.log(file.getName());
}
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `params` | `String` | The search criteria, as detailed in the [Google Drive SDK documentation](https://developers.google.com/drive/api/v2/ref-search-terms). |

#### Return


`https://developers.google.com/apps-script/reference/drive/file-iterator` --- A collection of all files that are children of the current folder and match the search
criteria.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `searchFolders(params)`

Gets a collection of all folders that are children of the current folder and match the given search
criteria. The search criteria are detailed in the [Google Drive SDK documentation](https://developers.google.com/drive/api/v2/ref-search-terms). Note that the Drive
service uses v2 of the Drive API and some query fields differ from v3. Review the [field
differences between v2 and v3](https://developers.google.com/drive/api/guides/v2-to-v3-reference#resource_field_differences_between_v2_and_v3).

The `params` argument is a query string that can contain string values, so take care
to escape quotation marks correctly (for example `"title contains 'Gulliver\\'s
Travels'"` or `'title contains "Gulliver\'s Travels"'`).

```javascript
// Logs the name of every folder that are children of the current folder and you own and is starred.
const folders = DriveApp.getRootFolder().searchFolders('starred = true and "me" in owners');
while (folders.hasNext()) {
  const folder = folders.next();
  console.log(folder.getName());
}
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `params` | `String` | The search criteria, as detailed in the [Google Drive SDK documentation](https://developers.google.com/drive/api/v2/ref-search-terms). |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder-iterator` --- A collection of all folders that are children of the current folder and match the search
criteria.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive.readonly`
- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setDescription(description)`

Sets the description for the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `description` | `String` | the new description for the `https://developers.google.com/apps-script/reference/drive/folder#` |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- this `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setName(name)`

Sets the name of the `https://developers.google.com/apps-script/reference/drive/folder#`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | the new name of the `https://developers.google.com/apps-script/reference/drive/folder#` |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- this `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setOwner(emailAddress)`

Changes the owner of the `https://developers.google.com/apps-script/reference/drive/folder#`. This method also gives the previous owner
explicit edit access to the `https://developers.google.com/apps-script/reference/drive/folder#`.

Drive does not support changing the ownership for items which are owned by gmail.com
accounts; it's supported for Workspace accounts.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `emailAddress` | `String` | The email address of the user who should become the new owner. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setOwner(user)`

Changes the owner of the `https://developers.google.com/apps-script/reference/drive/folder#`. This method also gives the previous owner
explicit edit access to the `https://developers.google.com/apps-script/reference/drive/folder#`.

Drive does not support changing the ownership for items which are owned by gmail.com
accounts; it's supported for Workspace accounts.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `user` | `https://developers.google.com/apps-script/reference/base/user.html` | A representation of the user who should become the new owner. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setSecurityUpdateEnabled(enabled)`

Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` requires a resource key for access when it's
shared using a link. Eligible files and folders are enabled by default.

Learn more about the [Security update for Google Drive](https://support.google.com/a/answer/10685032).

#### Parameters

| Name | Type | Description |
|---|---|---|
| `enabled` | `Boolean` | Whether to enable the resource key requirement for the `https://developers.google.com/apps-script/reference/drive/folder#`. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setShareableByEditors(shareable)`

Sets whether users with edit permissions to the `https://developers.google.com/apps-script/reference/drive/folder#` are allowed to share
with other users or change the permissions. The default for a new `https://developers.google.com/apps-script/reference/drive/folder#` is
`true`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `shareable` | `Boolean` | `true` if users with edit permissions should be allowed to share with other users or change the permissions; `false` if not. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- This `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setSharing(accessType, permissionType)`

Sets which class of users can access the `https://developers.google.com/apps-script/reference/drive/folder#` and what permissions
those users are granted, besides any individual users who have been explicitly given access.

```javascript
// Creates a folder that anyone on the Internet can read from and write to.
// (Domain administrators can prohibit this setting for users of a Google
// Workspace domain.)
const folder = DriveApp.createFolder('Shared Folder');
folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `accessType` | `https://developers.google.com/apps-script/reference/drive/access` | which class of users should be able to access the `https://developers.google.com/apps-script/reference/drive/folder#` |
| `permissionType` | `https://developers.google.com/apps-script/reference/drive/permission` | the permissions that should be granted to users who can access the `https://developers.google.com/apps-script/reference/drive/folder#` |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- this `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setStarred(starred)`

Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` is starred in the user's Drive. The default for
new `https://developers.google.com/apps-script/reference/drive/folder#`s is `false`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `starred` | `Boolean` | `true` if the `https://developers.google.com/apps-script/reference/drive/folder#` should be starred in the user's Drive; `false` if not |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- this `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `setTrashed(trashed)`

Sets whether the `https://developers.google.com/apps-script/reference/drive/folder#` is in the trash of the user's Drive. Only the
owner may trash the `https://developers.google.com/apps-script/reference/drive/folder#`. The default for new `https://developers.google.com/apps-script/reference/drive/folder#`s is `false`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `trashed` | `Boolean` | `true` if the `https://developers.google.com/apps-script/reference/drive/folder#` should be moved to the trash of the user's Drive; `false` if not |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- this `https://developers.google.com/apps-script/reference/drive/folder#`, for chaining

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

## Deprecated methods

### `addFile(child)`


**Deprecated.** Instead, use `https://developers.google.com/apps-script/reference/drive/file#moveTo(Folder)` or `https://developers.google.com/apps-script/reference/drive/folder#createShortcut(String)`.

Adds the given file to the current folder. This method does not move the file out of its
existing parent folder; a file can have more than one parent simultaneously.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `child` | `https://developers.google.com/apps-script/reference/drive/file` | The child file to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- The new parent of the file added as a child.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `addFolder(child)`


**Deprecated.** Instead, use `https://developers.google.com/apps-script/reference/drive/folder#moveTo(Folder)` or `https://developers.google.com/apps-script/reference/drive/folder#createShortcut(String)`.

Adds the given folder to the current folder. This method does not move the folder out of
its existing parent folder; a folder can have more than one parent simultaneously.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `child` | `https://developers.google.com/apps-script/reference/drive/folder#` | The child folder to add. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- The new parent of the folder added as a child.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeFile(child)`


**Deprecated.** Instead, use `https://developers.google.com/apps-script/reference/drive/file#moveTo(Folder)`.

Removes the given file from the current folder. This method does not delete the file, but
if a file is removed from all of its parents, it cannot be seen in Drive except by searching
for it or using the "All items" view.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `child` | `https://developers.google.com/apps-script/reference/drive/file` | The child file to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- The previous parent of the child.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`

*** ** * ** ***

### `removeFolder(child)`


**Deprecated.** Instead, use `https://developers.google.com/apps-script/reference/drive/folder#moveTo(Folder)`.

Removes the given folder from the current folder. This method does not delete the folder
or its contents, but if a folder is removed from all of its parents, it cannot be seen in Drive
except by searching for it or using the "All items" view.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `child` | `https://developers.google.com/apps-script/reference/drive/folder#` | The child folder to remove. |

#### Return


`https://developers.google.com/apps-script/reference/drive/folder#` --- The previous parent of the child.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/drive`