Stay organized with collections Save and categorize content based on your preferences.
FolderA folder in Google Drive. Folders can be accessed or created from DriveApp
.
// 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
addEditor(emailAddress)
Folder
Adds the given user to the list of editors for the Folder
. addEditor(user)
Folder
Adds the given user to the list of editors for the Folder
. addEditors(emailAddresses)
Folder
Adds the given array of users to the list of editors for the Folder
. addViewer(emailAddress)
Folder
Adds the given user to the list of viewers for the Folder
. addViewer(user)
Folder
Adds the given user to the list of viewers for the Folder
. addViewers(emailAddresses)
Folder
Adds the given array of users to the list of viewers for the Folder
. createFile(blob)
File
Creates a file in the current folder from a given Blob
of arbitrary data. createFile(name, content)
File
Creates a text file in the current folder with the given name and contents. createFile(name, content, mimeType)
File
Creates a file in the current folder with the given name, contents, and MIME type. createFolder(name)
Folder
Creates a folder in the current folder with the given name. createShortcut(targetId)
File
Creates a shortcut to the provided Drive item ID, and returns it. createShortcutForTargetIdAndResourceKey(targetId, targetResourceKey)
File
Creates a shortcut to the provided Drive item ID and resource key, and returns it. getAccess(email)
Permission
Gets the permission granted to a specific user. getAccess(user)
Permission
Gets the permission granted to a specific user. getDateCreated()
Date
Gets the date the Folder
was created. getDescription()
String
Gets the description for the Folder
. getEditors()
User[]
Gets the list of editors for this Folder
. getFiles()
FileIterator
Gets a collection of all files that are children of the current folder. getFilesByName(name)
FileIterator
Gets a collection of all files that are children of the current folder and have the given name. getFilesByType(mimeType)
FileIterator
Gets a collection of all files that are children of the current folder and have the given MIME type. getFolders()
FolderIterator
Gets a collection of all folders that are children of the current folder. getFoldersByName(name)
FolderIterator
Gets a collection of all folders that are children of the current folder and have the given name. getId()
String
Gets the ID of the Folder
. getLastUpdated()
Date
Gets the date the Folder
was last updated. getName()
String
Gets the name of the Folder
. getOwner()
User
Gets the owner of this Folder
. getParents()
FolderIterator
Gets a collection of folders that are immediate parents of the Folder
. getResourceKey()
String
Gets the resource key of the Folder
that is required to access items that have been shared using a link. getSecurityUpdateEligible()
Boolean
Gets whether this Folder
is eligible to apply the security update that requires a resource key for access when it's shared using a link. getSecurityUpdateEnabled()
Boolean
Gets whether this Folder
requires a resource key for access when it's shared using a link. getSharingAccess()
Access
Gets which class of users can access the Folder
, besides any individual users who have been explicitly given access. getSharingPermission()
Permission
Gets the permission granted to those users who can access the Folder
, besides any individual users who have been explicitly given access. getSize()
Integer
Gets the number of bytes used to store the Folder
in Drive. getUrl()
String
Gets the URL that can be used to open the Folder
in a Google App like Drive or Docs. getViewers()
User[]
Gets the list of viewers and commenters for this Folder
. isShareableByEditors()
Boolean
Determines whether users with edit permissions to the Folder
are allowed to share with other users or change the permissions. isStarred()
Boolean
Determines whether the Folder
has been starred in the user's Drive. isTrashed()
Boolean
Determines whether the Folder
is in the trash of the user's Drive. moveTo(destination)
Folder
Moves this item to the provided destination folder. removeEditor(emailAddress)
Folder
Removes the given user from the list of editors for the Folder
. removeEditor(user)
Folder
Removes the given user from the list of editors for the Folder
. removeViewer(emailAddress)
Folder
Removes the given user from the list of viewers and commenters for the Folder
. removeViewer(user)
Folder
Removes the given user from the list of viewers and commenters for the Folder
. revokePermissions(emailAddress)
Folder
Revokes the access to the Folder
granted to the given user. revokePermissions(user)
Folder
Revokes the access to the Folder
granted to the given user. searchFiles(params)
FileIterator
Gets a collection of all files that are children of the current folder and match the given search criteria. searchFolders(params)
FolderIterator
Gets a collection of all folders that are children of the current folder and match the given search criteria. setDescription(description)
Folder
Sets the description for the Folder
. setName(name)
Folder
Sets the name of the Folder
. setOwner(emailAddress)
Folder
Changes the owner of the Folder
. setOwner(user)
Folder
Changes the owner of the Folder
. setSecurityUpdateEnabled(enabled)
Folder
Sets whether the Folder
requires a resource key for access when it's shared using a link. setShareableByEditors(shareable)
Folder
Sets whether users with edit permissions to the Folder
are allowed to share with other users or change the permissions. setSharing(accessType, permissionType)
Folder
Sets which class of users can access the Folder
and what permissions those users are granted, besides any individual users who have been explicitly given access. setStarred(starred)
Folder
Sets whether the Folder
is starred in the user's Drive. setTrashed(trashed)
Folder
Sets whether the Folder
is in the trash of the user's Drive. Deprecated methods Detailed documentation addEditor(emailAddress)
Adds the given user to the list of editors for the Folder
. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.
emailAddress
String
The email address of the user to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addEditor(user)
Adds the given user to the list of editors for the Folder
. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.
user
User
A representation of the user to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addEditors(emailAddresses)
Adds the given array of users to the list of editors for the Folder
. If any of the users were already on the list of viewers, this method promotes them out of the list of viewers.
emailAddresses
String[]
An array of email addresses of the users to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addViewer(emailAddress)
Adds the given user to the list of viewers for the Folder
. If the user was already on the list of editors, this method has no effect.
emailAddress
String
The email address of the user to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addViewer(user)
Adds the given user to the list of viewers for the Folder
. If the user was already on the list of editors, this method has no effect.
user
User
A representation of the user to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addViewers(emailAddresses)
Adds the given array of users to the list of viewers for the Folder
. If any of the users were already on the list of editors, this method has no effect for them.
emailAddresses
String[]
An array of email addresses of the users to add. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
createFile(blob)
Creates a file in the current folder from a given Blob
of arbitrary data.
blob
BlobSource
The data for the new file. Return
File
— The new file.
Scripts that use this method require authorization with one or more of the following 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.
// 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
File
— The new file.
Scripts that use this method require authorization with one or more of the following 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.
// 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
File
— The new file.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
createFolder(name)
Creates a folder in the current folder with the given name.
Parameters Name Type Descriptionname
String
The name of the new folder. Return
Folder
— The new folder.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
createShortcut(targetId)
Creates a shortcut to the provided Drive item ID, and returns it.
Parameters Name Type DescriptiontargetId
String
The file ID of the target file or folder. Return
File
— The new shortcut.
Scripts that use this method require authorization with one or more of the following 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.
// 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
File
— The new shortcut.
Scripts that use this method require authorization with one or more of the following 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 Descriptionemail
String
The email address of the user whose permissions should be checked. Google Groups aren't supported. Return
Permission
— The permissions granted to the user.
Scripts that use this method require authorization with one or more of the following 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 Descriptionuser
User
A representation of the user whose permissions should be checked. Return
Permission
— The permissions granted to the user.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getDateCreated()
Gets the date the Folder
was created.
Date
— the date the Folder
was created
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getDescription()
Gets the description for the Folder
.
String
— the description for the Folder
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getEditors()
Gets the list of editors for this Folder
. If the user who executes the script does not have edit access to the Folder
, this method returns an empty array.
// 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
User[]
— The list of editors for this Folder
if the user has edit access or an empty array otherwise.
Scripts that use this method require authorization with one or more of the following 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.
ReturnFileIterator
— A collection of all files that are children of the current folder.
Scripts that use this method require authorization with one or more of the following 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 Descriptionname
String
The name of the files to find. Return
FileIterator
— A collection of all files that are children of the current folder and have the given name.
Scripts that use this method require authorization with one or more of the following 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 DescriptionmimeType
String
The MIME type of the files to find. Return
FileIterator
— A collection of all files that are children of the current folder and have the given MIME type.
Scripts that use this method require authorization with one or more of the following 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.
ReturnFolderIterator
— A collection of all folders that are children of the current folder.
Scripts that use this method require authorization with one or more of the following 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 Descriptionname
String
The name of the folders to find. Return
FolderIterator
— A collection of all folders that are children of the current folder and have the given name.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getId()
Gets the ID of the Folder
.
String
— the ID of the Folder
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getLastUpdated()
Gets the date the Folder
was last updated.
Date
— the date the Folder
was last updated
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getName()
Gets the name of the Folder
.
String
— the name of the Folder
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getOwner()
Gets the owner of this Folder
.
// 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
User
— The owner of this Folder
.
Scripts that use this method require authorization with one or more of the following 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 Folder
.
FolderIterator
— a collection of folders that are immediate parents of the Folder
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getResourceKey()
Gets the resource key of the Folder
that is required to access items that have been shared using a link.
String
— The resource key of the Folder
.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getSecurityUpdateEligible()
Gets whether this 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.
ReturnBoolean
— Whether the resource key requirement can be applied for the Folder
.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getSecurityUpdateEnabled()
Gets whether this 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.
ReturnBoolean
— Whether the resource key requirement is enabled for this Folder
.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getSharingAccess()
Gets which class of users can access the Folder
, besides any individual users who have been explicitly given access.
Access
— which class of users can access the Folder
Scripts that use this method require authorization with one or more of the following 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 Folder
, besides any individual users who have been explicitly given access.
Permission
— the permissions granted to users who can access the Folder
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getSize()
Gets the number of bytes used to store the Folder
in Drive. Note that Google Workspace application files do not count toward Drive storage limits and thus return 0
bytes.
Integer
— the number of bytes used to store the Folder
in Drive
Scripts that use this method require authorization with one or more of the following 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 Folder
in a Google App like Drive or Docs.
String
— the URL that can be used to view this Folder
in a Google App like Drive or Docs
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
getViewers()
Gets the list of viewers and commenters for this Folder
. If the user who executes the script does not have edit access to the Folder
, this method returns an empty array.
// 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
User[]
— The list of viewers and commenters for this Folder
if the user has edit access or an empty array otherwise.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
isStarred()
Determines whether the Folder
has been starred in the user's Drive.
Boolean
— true
if the Folder
is starred in the user's Drive; false
if not
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
isTrashed()
Determines whether the Folder
is in the trash of the user's Drive.
Boolean
— true
if the Folder
is in the trash of the user's Drive; false
if not
Scripts that use this method require authorization with one or more of the following 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 Descriptiondestination
Folder
The folder that becomes the new parent. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeEditor(emailAddress)
Removes the given user from the list of editors for the Folder
. This method doesn't block users from accessing the Folder
if they belong to a class of users who have general access—for example, if the Folder
is shared with the user's entire domain, or if the 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 DescriptionemailAddress
String
The email address of the user to remove. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeEditor(user)
Removes the given user from the list of editors for the Folder
. This method doesn't block users from accessing the Folder
if they belong to a class of users who have general access—for example, if the Folder
is shared with the user's entire domain, or if the 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 Descriptionuser
User
A representation of the user to remove. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeViewer(emailAddress)
Removes the given user from the list of viewers and commenters for the 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 Folder
if they belong to a class of users who have general access—for example, if the Folder
is shared with the user's entire domain, or if the 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 DescriptionemailAddress
String
The email address of the user to remove. Return
Folder
— This Folder
for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeViewer(user)
Removes the given user from the list of viewers and commenters for the 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 Folder
if they belong to a class of users who have general access—for example, if the Folder
is shared with the user's entire domain, or if the 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 Descriptionuser
User
A representation of the user to remove. Return
Folder
— This Folder
for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
revokePermissions(emailAddress)
Revokes the access to the Folder
granted to the given user. This method doesn't block users from accessing the Folder
if they belong to a class of users who have general access — for example, if the Folder
is shared with the user's entire domain.
emailAddress
String
The email address of the user whose access should be revoked. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
revokePermissions(user)
Revokes the access to the Folder
granted to the given user. This method doesn't block users from accessing the Folder
if they belong to a class of users who have general access — for example, if the Folder
is shared with the user's entire domain.
user
User
A representation of the user whose access should be revoked. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following 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. 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.
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"'
).
// 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 Return
FileIterator
— A collection of all files that are children of the current folder and match the search criteria.
Scripts that use this method require authorization with one or more of the following 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. 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.
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"'
).
// 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 Return
FolderIterator
— A collection of all folders that are children of the current folder and match the search criteria.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive
setDescription(description)
Sets the description for the Folder
.
description
String
the new description for the Folder
Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setName(name)
Sets the name of the Folder
.
name
String
the new name of the Folder
Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setOwner(emailAddress)
Changes the owner of the Folder
. This method also gives the previous owner explicit edit access to the Folder
.
emailAddress
String
the email address of the user who should become the new owner Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setOwner(user)
Changes the owner of the Folder
. This method also gives the previous owner explicit edit access to the Folder
.
user
User
a representation of the user who should become the new owner Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setSecurityUpdateEnabled(enabled)
Sets whether the 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.
Parameters Name Type Descriptionenabled
Boolean
Whether to enable the resource key requirement for the Folder
. Return
Folder
— This Folder
, for chaining.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setSharing(accessType, permissionType)
Sets which class of users can access the Folder
and what permissions those users are granted, besides any individual users who have been explicitly given access.
// 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
Access
which class of users should be able to access the Folder
permissionType
Permission
the permissions that should be granted to users who can access the Folder
Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setStarred(starred)
Sets whether the Folder
is starred in the user's Drive. The default for new Folder
s is false
.
starred
Boolean
true
if the Folder
should be starred in the user's Drive; false
if not Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
setTrashed(trashed)
Sets whether the Folder
is in the trash of the user's Drive. Only the owner may trash the Folder
. The default for new Folder
s is false
.
trashed
Boolean
true
if the Folder
should be moved to the trash of the user's Drive; false
if not Return
Folder
— this Folder
, for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addFile(child)
Deprecated. Instead, use File.moveTo(destination)
or createShortcut(targetId)
.
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 Descriptionchild
File
The child file to add. Return
Folder
— The new parent of the file added as a child.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
addFolder(child)
Deprecated. Instead, use moveTo(destination)
or createShortcut(targetId)
.
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 Descriptionchild
Folder
The child folder to add. Return
Folder
— The new parent of the folder added as a child.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeFile(child)
Deprecated. Instead, use File.moveTo(destination)
.
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 Descriptionchild
File
The child file to remove. Return
Folder
— The previous parent of the child.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
removeFolder(child)
Deprecated. Instead, use moveTo(destination)
.
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 Descriptionchild
Folder
The child folder to remove. Return
Folder
— The previous parent of the child.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/drive
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["The `Folder` object in Google Apps Script provides methods for programmatically managing Google Drive folders."],["You can use these methods to create, organize, share, and retrieve information about folders and their contents."],["Most methods require authorization with the `https://www.googleapis.com/auth/drive` scope."],["The documentation provides detailed explanations and code examples for each method, including parameters, return types, and authorization scopes."],["Some methods are deprecated and should be replaced with their recommended alternatives for better compatibility."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4