Drive Service - Apps Script - Google For Developers
Drive Service - Apps Script - Google For Developers
Drive Service
This service lets scripts create, find, and modify files and folders in Google Drive. Although
the built-in Drive service is easier to use, it has some limitations. For the most up-to-date
features and support, and to access files or folders in shared drives, use the advanced Drive
service (/apps-script/advanced/drive).
The following code sample shows how to log the names of each file in the user's My Drive
folder:
Note: Google Workspace Administrators can turn off the Drive SDK (/drive) for their domain, which
prevents their users from installing and using Google Drive apps. This setting also prevents users from
using Apps Script scripts, web apps and add-ons that use the Drive service
(/apps-script/reference/drive) or Advanced Drive Service (/apps-script/advanced/drive) (even if the add-
on or web app was installed before the admin turned off the Drive SDK (/drive)).
However, if an add-on using the Drive service is published for domain-wide installation and is installed by
the administrator for some or all users in the domain, or any script that has its OAuth client allowlisted
(https://support.google.com/a/answer/162106) by the domain administrator, the add-on functions for
those users even if the Drive SDK (/drive) is turned off in the domain.
Classes
Name Brief description
https://developers.google.com/apps-script/reference/drive 1/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
DriveApp Allows scripts to create, find, and modify files and folders in
(/apps-script/reference/drive/drive-app) Google Drive.
Access (/apps-script/reference/drive/access)
Properties
DOMAIN_WITH_LINK Enum People in your domain who have the link can access.
DriveApp (/apps-script/reference/drive/drive-app)
https://developers.google.com/apps-script/reference/drive 2/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
Properties
Methods
https://developers.google.com/apps-script/reference/drive 3/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tFiles()
(/apps-script/reference/drive/drive-app#getFiles()) FileIterator Gets a collec
(/apps- all files in the
script/reference/drive/file- Drive.
iterator)
https://developers.google.com/apps-script/reference/drive 4/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
https://developers.google.com/apps-script/reference/drive 5/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
File (/apps-script/reference/drive/file)
Methods
dCommenter(emailAddress) File Ad
apps-script/reference/drive/file#addCommenter(String)) (/apps-script/reference/drive/file) lis
Fi
(/
sc
.
dCommenter(user) File Ad
apps-script/reference/drive/file#addCommenter(User)) (/apps-script/reference/drive/file) lis
Fi
(/
sc
.
dCommenters(emailAddresses) File Ad
apps-script/reference/drive/file#addCommenters(String)) (/apps-script/reference/drive/file) us
co
(/
sc
.
dEditor(emailAddress) File Ad
apps-script/reference/drive/file#addEditor(String)) (/apps-script/reference/drive/file) lis
(/
sc
.
dEditor(user) File Ad
apps-script/reference/drive/file#addEditor(User)) (/apps-script/reference/drive/file) lis
(/
sc
.
https://developers.google.com/apps-script/reference/drive 6/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
dEditors(emailAddresses) File Ad
apps-script/reference/drive/file#addEditors(String)) (/apps-script/reference/drive/file) us
fo
(/
sc
.
dViewer(emailAddress) File Ad
apps-script/reference/drive/file#addViewer(String)) (/apps-script/reference/drive/file) lis
Fi
(/
sc
.
dViewer(user) File Ad
apps-script/reference/drive/file#addViewer(User)) (/apps-script/reference/drive/file) lis
Fi
(/
sc
.
dViewers(emailAddresses) File Ad
apps-script/reference/drive/file#addViewers(String)) (/apps-script/reference/drive/file) us
fo
(/
sc
.
tAccess(email) Permission Ge
apps-script/reference/drive/file#getAccess(String)) (/apps- gr
script/reference/drive/permission)
tAccess(user) Permission Ge
apps-script/reference/drive/file#getAccess(User)) (/apps- gr
script/reference/drive/permission)
tAs(contentType) Blob Re
apps-script/reference/drive/file#getAs(String)) (https://developers.google.com/apps-ob
script/reference/base/blob.html) to
typ
tBlob()
(/apps-script/reference/drive/file#getBlob()) Blob Re
(https://developers.google.com/apps-ob
script/reference/base/blob.html)
tDateCreated() Date Ge
apps-script/reference/drive/file#getDateCreated()) (/
sc
wa
https://developers.google.com/apps-script/reference/drive 7/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tDescription() String Ge
apps-script/reference/drive/file#getDescription()) th
(/
sc
.
tDownloadUrl() String Ge
apps-script/reference/drive/file#getDownloadUrl()) us
tEditors()
(/apps-script/reference/drive/file#getEditors()) User[] Ge
(/apps-script/reference/drive/user) th
(/
sc
.
tId()
(/apps-script/reference/drive/file#getId()) String Ge
(/
sc
.
tLastUpdated() Date Ge
apps-script/reference/drive/file#getLastUpdated()) (/
sc
wa
tMimeType()
(/apps-script/reference/drive/file#getMimeType()) String Ge
file
tName()
(/apps-script/reference/drive/file#getName()) String Ge
Fi
(/
sc
.
tOwner()
(/apps-script/reference/drive/file#getOwner()) User Ge
(/apps-script/reference/drive/user)
tParents()
(/apps-script/reference/drive/file#getParents()) FolderIterator Ge
(/apps-script/reference/drive/folder- fo
iterator) pa
(/
sc
.
tResourceKey() String Ge
apps-script/reference/drive/file#getResourceKey()) th
(/
sc
th
https://developers.google.com/apps-script/reference/drive 8/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
ite
sh
tSecurityUpdateEligible() Boolean Ge
apps-script/reference/drive/file#getSecurityUpdateEligible()) (/
sc
is
se
re
ac
us
tSecurityUpdateEnabled() Boolean Ge
apps-script/reference/drive/file#getSecurityUpdateEnabled()) (/
sc
re
ac
us
tSharingAccess() Access Ge
apps-script/reference/drive/file#getSharingAccess()) (/apps-script/reference/drive/access) ca
(/
sc
,b
us
ex
tSharingPermission() Permission Ge
apps-script/reference/drive/file#getSharingPermission()) (/apps- gr
script/reference/drive/permission) wh
(/
sc
,b
us
ex
tSize()
(/apps-script/reference/drive/file#getSize()) Integer Ge
us
(/
sc
in
tTargetId()
(/apps-script/reference/drive/file#getTargetId()) String If t
ret
it p
tTargetMimeType() String If t
apps-script/reference/drive/file#getTargetMimeType()) ret
th
https://developers.google.com/apps-script/reference/drive 9/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tTargetResourceKey() String If t
apps-script/reference/drive/file#getTargetResourceKey()) ret
of
tThumbnail() Blob Ge
apps-script/reference/drive/file#getThumbnail()) (https://developers.google.com/apps-fo
script/reference/base/blob.html) th
tUrl()
(/apps-script/reference/drive/file#getUrl()) String Ge
us
(/
sc
in
or
tViewers()
(/apps-script/reference/drive/file#getViewers()) User[] Ge
(/apps-script/reference/drive/user) an
Fi
(/
sc
.
ShareableByEditors() Boolean De
apps-script/reference/drive/file#isShareableByEditors()) wi
th
(/
sc
ar
ot
pe
Starred()
(/apps-script/reference/drive/file#isStarred()) Boolean De
Fi
(/
sc
ha
us
Trashed()
(/apps-script/reference/drive/file#isTrashed()) Boolean De
Fi
(/
sc
is
Dr
keCopy()
(/apps-script/reference/drive/file#makeCopy()) File Cr
(/apps-script/reference/drive/file)
https://developers.google.com/apps-script/reference/drive 10/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
keCopy(destination) File Cr
apps-script/reference/drive/file#makeCopy(Folder)) (/apps-script/reference/drive/file) in
dir
keCopy(name) File Cr
apps-script/reference/drive/file#makeCopy(String)) (/apps-script/reference/drive/file) an
na
veTo(destination) File M
apps-script/reference/drive/file#moveTo(Folder)) (/apps-script/reference/drive/file) pr
fo
moveCommenter(emailAddress) File Re
apps-script/reference/drive/file#removeCommenter(String)) (/apps-script/reference/drive/file) fro
co
(/
sc
.
moveCommenter(user) File Re
apps-script/reference/drive/file#removeCommenter(User)) (/apps-script/reference/drive/file) fro
co
(/
sc
.
moveEditor(emailAddress) File Re
apps-script/reference/drive/file#removeEditor(String)) (/apps-script/reference/drive/file) fro
th
(/
sc
.
moveEditor(user) File Re
apps-script/reference/drive/file#removeEditor(User)) (/apps-script/reference/drive/file) fro
th
(/
sc
.
moveViewer(emailAddress) File Re
apps-script/reference/drive/file#removeViewer(String)) (/apps-script/reference/drive/file) fro
an
Fi
https://developers.google.com/apps-script/reference/drive 11/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
(/
sc
.
moveViewer(user) File Re
apps-script/reference/drive/file#removeViewer(User)) (/apps-script/reference/drive/file) fro
an
Fi
(/
sc
.
vokePermissions(emailAddress) File Re
apps-script/reference/drive/file#revokePermissions(String)) (/apps-script/reference/drive/file) Fi
(/
sc
gr
vokePermissions(user) File Re
apps-script/reference/drive/file#revokePermissions(User)) (/apps-script/reference/drive/file) Fi
(/
sc
gr
tContent(content) File Ov
apps-script/reference/drive/file#setContent(String)) (/apps-script/reference/drive/file) th
re
tDescription(description) File Se
apps-script/reference/drive/file#setDescription(String)) (/apps-script/reference/drive/file) th
(/
sc
.
tName(name) File Se
apps-script/reference/drive/file#setName(String)) (/apps-script/reference/drive/file) Fi
(/
sc
.
tOwner(emailAddress) File Ch
apps-script/reference/drive/file#setOwner(String)) (/apps-script/reference/drive/file) Fi
(/
sc
.
tOwner(user) File Ch
apps-script/reference/drive/file#setOwner(User)) (/apps-script/reference/drive/file) Fi
https://developers.google.com/apps-script/reference/drive 12/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
(/
sc
.
tSecurityUpdateEnabled(enabled) File Se
apps- (/apps-script/reference/drive/file) (/
script/reference/drive/file#setSecurityUpdateEnabled(Boolean)) sc
re
ac
us
tShareableByEditors(shareable) File Se
apps- (/apps-script/reference/drive/file) ed
script/reference/drive/file#setShareableByEditors(Boolean)) Fi
(/
sc
ar
ot
pe
tStarred(starred) File Se
apps-script/reference/drive/file#setStarred(Boolean)) (/apps-script/reference/drive/file) (/
sc
is
Dr
tTrashed(trashed) File Se
apps-script/reference/drive/file#setTrashed(Boolean)) (/apps-script/reference/drive/file) (/
sc
is
Dr
FileIterator (/apps-script/reference/drive/file-iterator)
Methods
https://developers.google.com/apps-script/reference/drive 13/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
Folder (/apps-script/reference/drive/folder)
Methods
dEditor(emailAddress)
(/apps-script/reference/drive/folder#addEditor(String)) Folder
(/apps-
script/reference/
dEditor(user)
(/apps-script/reference/drive/folder#addEditor(User)) Folder
(/apps-
script/reference/
dEditors(emailAddresses)
(/apps-script/reference/drive/folder#addEditors(String)) Folder
(/apps-
script/reference/
dViewer(emailAddress)
(/apps-script/reference/drive/folder#addViewer(String)) Folder
(/apps-
script/reference/
https://developers.google.com/apps-script/reference/drive 14/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
dViewer(user)
(/apps-script/reference/drive/folder#addViewer(User)) Folder
(/apps-
script/reference/
dViewers(emailAddresses)
(/apps-script/reference/drive/folder#addViewers(String)) Folder
(/apps-
script/reference/
eateFile(blob)
(/apps-script/reference/drive/folder#createFile(BlobSource)) File
(/apps-script/ref
eateFolder(name)
(/apps-script/reference/drive/folder#createFolder(String)) Folder
(/apps-
script/reference/
eateShortcut(targetId)
(/apps-script/reference/drive/folder#createShortcut(String)) File
(/apps-script/ref
tAccess(email)
(/apps-script/reference/drive/folder#getAccess(String)) Permission
(/apps-
script/reference/
tAccess(user)
(/apps-script/reference/drive/folder#getAccess(User)) Permission
(/apps-
script/reference/
https://developers.google.com/apps-script/reference/drive 15/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tDateCreated()
(/apps-script/reference/drive/folder#getDateCreated()) Date
tDescription()
(/apps-script/reference/drive/folder#getDescription()) String
tEditors()
(/apps-script/reference/drive/folder#getEditors()) User[]
(/apps-
script/reference/
tFiles()
(/apps-script/reference/drive/folder#getFiles()) FileIterator
(/apps-script/ref
iterator)
tFilesByName(name)
(/apps-script/reference/drive/folder#getFilesByName(String)) FileIterator
(/apps-script/ref
iterator)
tFilesByType(mimeType) FileIterator
apps-script/reference/drive/folder#getFilesByType(String)) (/apps-script/ref
iterator)
tFolders()
(/apps-script/reference/drive/folder#getFolders()) FolderIterato
(/apps-
script/reference/
iterator)
tFoldersByName(name) FolderIterato
apps-script/reference/drive/folder#getFoldersByName(String)) (/apps-
script/reference/
iterator)
tId()
(/apps-script/reference/drive/folder#getId()) String
https://developers.google.com/apps-script/reference/drive 16/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tLastUpdated()
(/apps-script/reference/drive/folder#getLastUpdated()) Date
tName()
(/apps-script/reference/drive/folder#getName()) String
tOwner()
(/apps-script/reference/drive/folder#getOwner()) User
(/apps-
script/reference/
tParents()
(/apps-script/reference/drive/folder#getParents()) FolderIterato
(/apps-
script/reference/
iterator)
tResourceKey()
(/apps-script/reference/drive/folder#getResourceKey()) String
tSecurityUpdateEligible() Boolean
apps-script/reference/drive/folder#getSecurityUpdateEligible())
tSecurityUpdateEnabled() Boolean
apps-script/reference/drive/folder#getSecurityUpdateEnabled())
https://developers.google.com/apps-script/reference/drive 17/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tSharingAccess()
(/apps-script/reference/drive/folder#getSharingAccess()) Access
(/apps-
script/reference/
tSharingPermission()
(/apps-script/reference/drive/folder#getSharingPermission()) Permission
(/apps-
script/reference/
tSize()
(/apps-script/reference/drive/folder#getSize()) Integer
tUrl()
(/apps-script/reference/drive/folder#getUrl()) String
tViewers()
(/apps-script/reference/drive/folder#getViewers()) User[]
(/apps-
script/reference/
ShareableByEditors()
(/apps-script/reference/drive/folder#isShareableByEditors()) Boolean
Starred()
(/apps-script/reference/drive/folder#isStarred()) Boolean
https://developers.google.com/apps-script/reference/drive 18/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
Trashed()
(/apps-script/reference/drive/folder#isTrashed()) Boolean
veTo(destination)
(/apps-script/reference/drive/folder#moveTo(Folder)) Folder
(/apps-
script/reference/
moveEditor(emailAddress) Folder
apps-script/reference/drive/folder#removeEditor(String)) (/apps-
script/reference/
moveEditor(user)
(/apps-script/reference/drive/folder#removeEditor(User)) Folder
(/apps-
script/reference/
moveViewer(emailAddress) Folder
apps-script/reference/drive/folder#removeViewer(String)) (/apps-
script/reference/
moveViewer(user)
(/apps-script/reference/drive/folder#removeViewer(User)) Folder
(/apps-
script/reference/
vokePermissions(emailAddress) Folder
apps-script/reference/drive/folder#revokePermissions(String)) (/apps-
script/reference/
https://developers.google.com/apps-script/reference/drive 19/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
vokePermissions(user) Folder
apps-script/reference/drive/folder#revokePermissions(User)) (/apps-
script/reference/
archFiles(params)
(/apps-script/reference/drive/folder#searchFiles(String)) FileIterator
(/apps-script/ref
iterator)
archFolders(params)
(/apps-script/reference/drive/folder#searchFolders(String)) FolderIterato
(/apps-
script/reference/
iterator)
tDescription(description) Folder
apps-script/reference/drive/folder#setDescription(String)) (/apps-
script/reference/
tName(name)
(/apps-script/reference/drive/folder#setName(String)) Folder
(/apps-
script/reference/
tOwner(emailAddress)
(/apps-script/reference/drive/folder#setOwner(String)) Folder
(/apps-
script/reference/
tOwner(user)
(/apps-script/reference/drive/folder#setOwner(User)) Folder
(/apps-
script/reference/
tSecurityUpdateEnabled(enabled) Folder
apps-script/reference/drive/folder#setSecurityUpdateEnabled(Boolean)) (/apps-
script/reference/
https://developers.google.com/apps-script/reference/drive 20/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tShareableByEditors(shareable) Folder
apps-script/reference/drive/folder#setShareableByEditors(Boolean)) (/apps-
script/reference/
tStarred(starred)
(/apps-script/reference/drive/folder#setStarred(Boolean)) Folder
(/apps-
script/reference/
tTrashed(trashed)
(/apps-script/reference/drive/folder#setTrashed(Boolean)) Folder
(/apps-
script/reference/
FolderIterator (/apps-script/reference/drive/folder-iterator)
Methods
https://developers.google.com/apps-script/reference/drive 21/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
(/apps-
script/reference/drive/folder-
iterator#next())
will return an item.
Permission (/apps-script/reference/drive/permission)
Properties
VIEW EnumUsers who can access the file or folder are able only to view it or copy it.
EDIT EnumUsers who can access the file or folder are able to edit it.
COMMENT EnumUsers who can access the file or folder are able only to view it, copy it, or
comment on it.
ORGANIZER EnumUsers who can organize files and folders within a shared drive.
FILE_ EnumUsers who can edit, trash, and move content within a shared drive.
ORGANIZER
NONE EnumThe user does not have any permissions for the file or folder.
User (/apps-script/reference/drive/user)
Methods
Return
Method Brief description
type
https://developers.google.com/apps-script/reference/drive 22/23
6/27/25, 10:10 AM Drive Service | Apps Script | Google for Developers
tName()
(/apps-script/reference/drive/user#getName()) String Gets the user's name.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0
License (https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the Apache
2.0 License (https://www.apache.org/licenses/LICENSE-2.0). For details, see the Google Developers Site
Policies (https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its
affiliates.
https://developers.google.com/apps-script/reference/drive 23/23