Deprecated. The DocsList service was deprecated on December 11, 2014. To work with files in Google Drive, use the Drive service instead.
A folder contains methods to create, find, and access files inside of itself.
// This example gets a folder named 'kittens' and logs the files it contains.
var folder = DocsList.getFolder('kittens');
var files = folder.getFiles();
for (var i in files) {
Logger.log(files[i].getName());
}
Deprecated methods
Method | Return type | Brief description |
---|---|---|
|
| Adds the given user to the list of editors for the . |
|
| Adds the given user to the list of editors for the . |
|
| Adds the given array of users to the list of editors for the . |
| void | Adds the item to the given folder. |
|
| Adds the given user to the list of viewers for the . |
|
| Adds the given user to the list of viewers for the . |
|
| Adds the given array of users to the list of viewers for the . |
|
| Creates a file using the data stored in this blob. |
|
| Creates a file with the given name and contents in the current folder. |
|
| Creates a file with the given name and contents in the current folder with the given MIME type. |
|
| Creates a sub-folder with the given name in the current folder. |
|
| Returns an array of all the files in the container that contain the given string. |
|
| Returns a subrange of the files that result from the given query. |
|
| Returns the next number files maching the search query and a paging token. |
|
| Returns the next number files maching the search query,
picking up from where the token from the previous lookup left off. |
| Date | Gets the date that this item was created. |
| String | Returns the description of the item or null if a description doesn't exist. |
| User[] | Gets the list of editors for this . |
|
| Returns all the files in the container (up to a maximum of
). |
|
| Returns a subrange of the files in this container. |
|
| Returns all files of a given type. |
|
| Returns a subrange of the files of the given type in this container. |
|
| Returns all files of a given type. |
|
| Returns files matching the given type. |
|
| Returns the next number files of the given type in this container and a
paging token. |
|
| Returns the next number files of the given type in this container,
picking up from where the token from the previous lookup left off. |
|
| Returns the next number files in this container and a paging token. |
|
| Returns the next number files in this container, picking up
from where the token from the previous lookup left off. |
|
| Returns all the folders in this container (up to a maximum of
). |
|
| Returns a subrange of the folders in this container. |
|
| Returns the first number of folders in this container and a paging token. |
|
| Returns the next number folders in this container, picking up
from where the token from the previous lookup left off. |
| String | Returns the document ID associated with the item. |
| Date | Gets the date that this item was last updated. |
| String | Returns the name of the item. |
| User | Gets the owner of the item. |
|
| Returns the parent folders. |
| Integer | Returns the amount of disk space used by the item. |
| String | Returns a URL to access the particular item. |
| User[] | Gets the list of viewers and commenters for this . |
| Boolean | Gets whether the item is starred. |
| Boolean | Checks whether the item is trashed. |
|
| Removes the given user from the list of editors for the . |
|
| Removes the given user from the list of editors for the . |
| void | Removes this object from the given folder. |
|
| Removes the given user from the list of viewers and commenters for the . |
|
| Removes the given user from the list of viewers and commenters for the . |
| void | Rename the item. |
| void | Update's the item's description. |
| void | Sets the item's starred status in drive. |
| void | Sets the trashed status of an item but does not permanently delete it. |
Deprecated methods
addEditor(emailAddress)
addEditor(emailAddress)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given user to the list of editors for the
. If the user was already
on the list of viewers, this method promotes the user out of the list of viewers.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddress | String | the email address of the user to add |
Return
addEditor(user)
addEditor(user)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given user to the list of editors for the
. If the user was already
on the list of viewers, this method promotes the user out of the list of viewers.Folder
Parameters
Name | Type | Description |
---|---|---|
user | User | a representation of the user to add |
Return
addEditors(emailAddresses)
addEditors(emailAddresses)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given array of users to the list of editors for the
. If any of the
users were already on the list of viewers, this method promotes them out of the list of
viewers.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddresses | String[] | an array of email addresses of the users to add |
Return
addToFolder(parent)
addToFolder(parent)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the item to the given folder.
// This example creates a new file and adds it to a folder
// Note: This can also be used on a folder to add it to another folder
var file = DocsList.createFile('my test file', 'test file contents');
var folder = DocsList.createFolder('My Test Folder');
file.addToFolder(folder);
Logger.log(file.getParents()[0].getName()); // logs 'My Test Folder'
Parameters
Name | Type | Description |
---|---|---|
parent |
| the folder to add the item to |
addViewer(emailAddress)
addViewer(emailAddress)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given user to the list of viewers for the
. If the user was already
on the list of editors, this method has no effect.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddress | String | the email address of the user to add |
Return
addViewer(user)
addViewer(user)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given user to the list of viewers for the
. If the user was already
on the list of editors, this method has no effect.Folder
Parameters
Name | Type | Description |
---|---|---|
user | User | a representation of the user to add |
Return
addViewers(emailAddresses)
addViewers(emailAddresses)
Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given array of users to the list of viewers for the
. If any of the
users were already on the list of editors, this method has no effect for them.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddresses | String[] | an array of email addresses of the users to add |
Return
createFile(blob)
createFile(blob)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a file using the data stored in this blob.
// Fetches the Google logo and saves it to a folder
var url = 'https://www.google.com/images/srpr/logo3w.png';
var imageBlob = UrlFetchApp.fetch(url).getBlob();
var folder = DocsList.createFolder('my folder');
folder.createFile(imageBlob);
Parameters
Name | Type | Description |
---|---|---|
blob | BlobSource | the blob to create the file from |
Return
— the newly created fileFile
createFile(name, contents)
createFile(name, contents)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a file with the given name and contents in the current folder. If the file name does not contain an extension, it defaults to plain text.
// Creates a file called 'new kitten' in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
folder.createFile('new kitten', 'meow');
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the new file |
contents | String | the contents of the new file |
Return
— the newly created fileFile
createFile(name, contents, mimeType)
createFile(name, contents, mimeType)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a file with the given name and contents in the current folder with the given MIME type. If the file name does not contain an extension, it defaults to plain text.
// Creates a simple XML file in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var contents = '<kitten><name>Tiny</name><age>1</age></kitten>';
folder.createFile('kittens.xml', contents, 'application/xml');
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the new file |
contents | String | the new file contents |
mimeType | String | the mime-type of the new file |
Return
— the newly created fileFile
createFolder(name)
createFolder(name)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a sub-folder with the given name in the current folder.
// Creates a subfolder in a folder called 'cats'
var folder = DocsList.createFolder('cats');
folder.createFolder('cool cats');
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the new folder |
Return
— the newly created folderFolder
find(query)
find(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns an array of all the files in the container that contain the given string.
// Logs the name of all the files resulting from a search for 'cool cats'
var folder = DocsList.getFolder('cats');
var coolCats = folder.find('cool cats');
for (var i in coolCats) {
Logger.log(coolCats[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
query | String | the search string |
Return
— the matching filesFile[]
find(query, start, max)
find(query, start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a subrange of the files that result from the given query. If there are not enough results to fill the range, a partial range will be returned.
// Logs the name of the first 3 files resulting from a search for 'cool cats'
var folder = DocsList.getFolder('cats');
var coolCats = folder.find('cool cats', 0, 3);
for (var i in coolCats) {
Logger.log(coolCats[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
query | String | the search string |
start | Integer | the 0-indexed position to start returning results from |
max | Integer | the maximum number of objects to return |
Return
— the requested number of matching filesFile[]
findForPaging(query, number)
findForPaging(query, number)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files maching the search query and a paging token.
If the requested number of files do not exist, it returns the available
files.
// Logs the name of the first 3 files resulting from a search for 'cool cats'
var folder = DocsList.getFolder('cats');
var filesResult = folder.findForPaging('cool cats', 3);
var files = FilesResult.getFiles();
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
query | String | the search string |
number | Integer | the number of objects to return |
Return
— the requested number of matching files and a paging tokenFilesResult
findForPaging(query, number, token)
findForPaging(query, number, token)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files maching the search query,
picking up from where the token
from the previous lookup left off.
If the requested number of files do not exist, it returns the available
files.
// Logs the first 6 file names resulting from a search but does it 3 at
// a time.
var folder = DocsList.getFolder('cats');
var filesResult = folder.findForPaging('cool cats', 3);
var files = filesResult.getFiles();
var token = filesResult.getToken();
// log the first 3 file names
for (var i in files) {
Logger.log(files[i].getName());
}
filesResult = folder.findForPaging('cool cats', 3, token); // pass in previous token
files = filesResult.getFiles();
// log the next 3 file names
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
query | String | the search string |
number | Integer | the number of objects to return |
token |
| the token from the previous lookup |
Return
— the requested number of matching files and a paging tokenFilesResult
getDateCreated()
getDateCreated()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the date that this item was created.
// This example logs the date the first file was created.
// Note: This can also be used on a folder
var file = DocsList.getAllFiles[0];
Logger.log(file.getDateCreated());
Return
Date
— the date this item was created
getDescription()
getDescription()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the description of the item or null if a description doesn't exist.
// Gets the first document's description.
// Note: This can also be used on a folder
var doc = DocsList.getFilesByType(DocsList.FileType.DOCUMENT)[0];
Logger.log(doc.getDescription());
Return
String
— the item's description
getEditors()
getEditors()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the list of editors for this
. If the user who executes the script does
not have edit access to the Folder
, this method throws an exception.Folder
Return
User[]
— an array of users with edit permission
getFiles()
getFiles()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns all the files in the container (up to a maximum of
).
DocsList.DEFAULT_RESULT_SIZE
// Logs the number of files in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var files = folder.getFiles();
Logger.log(files.length);
Return
— the requested filesFile[]
getFiles(start, max)
getFiles(start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a subrange of the files in this container. If there are not enough results to fill the range, a partial range will be returned.
// Logs the first 3 file names (or less if there are fewer
// than 3 files) in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var files = folder.getFiles(0, 3);
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
start | Integer | the 0-indexed position to start returning results from |
max | Integer | the maximum number of files to return |
Return
— the requested filesFile[]
getFilesByType(type)
getFilesByType(type)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns all files of a given type.
See
for the list of possible file types.
FileType
// Logs the names of the first document in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var file = folder.getFilesByType(DocsList.FileType.DOCUMENT)[0];
Logger.log(file.getName());
Parameters
Name | Type | Description |
---|---|---|
type |
| the type of files to get |
Return
— the requested filesFile[]
See also
getFilesByType(type, start, max)
getFilesByType(type, start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a subrange of the files of the given type in this container.
If there are not enough results to fill the range, a partial range will be
returned. See
for the list of possible file types.
FileType
// Logs the names of the first three documents in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var files = folder.getFilesByType(DocsList.FileType.DOCUMENT, 0, 3);
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
type |
| |
start | Integer | the 0-indexed position to start returning results from |
max | Integer | the maximum number of files to return |
Return
— the requested filesFile[]
See also
getFilesByType(fileType)
getFilesByType(fileType)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns all files of a given type.
Parameters
Name | Type | Description |
---|---|---|
fileType | String | the type of files to get; legal values are: "spreadsheet", "document" and "presentation" |
Return
getFilesByType(fileType, start, max)
getFilesByType(fileType, start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns files matching the given type. This function returns a sub-range of the results. If there are not enough results to fill the range, a partial range will be returned.
Parameters
Name | Type | Description |
---|---|---|
fileType | String | the type of files to get; legal values are: "spreadsheet", "document" and "presentation" |
start | Integer | the 0-indexed position start returning results from |
max | Integer | the maximum number of objects to return |
Return
getFilesByTypeForPaging(type, number)
getFilesByTypeForPaging(type, number)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files of the given type in this container and a
paging token.
If the requested number of files do not exist, it returns the available
files.
// Logs the first 3 document names (or less if there are fewer
// than 3 documents) from the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var filesResult = folder.getFilesForPaging(DocsList.FileType.DOCUMENT, 3);
var files = FilesResult.getFiles();
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
type |
| the type of files to get |
number | Integer | the number of files to get |
Return
— the requested files and a paging tokenFilesResult
See also
getFilesByTypeForPaging(type, number, token)
getFilesByTypeForPaging(type, number, token)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files of the given type in this container,
picking up from where the token
from the previous lookup left off.
If the requested number of files do not exist, it returns the available
files.
// Logs the first 6 document names in the 'kittens' folder but does it 3 at
// a time.
var folder = DocsList.getFolder('kittens');
var filesResult = folder.getFilesForPaging(DocsList.FileType.DOCUMENT, 3);
var files = filesResult.getFiles();
var token = filesResult.getToken();
// log the first 3 document names
for (var i in files) {
Logger.log(files[i].getName());
}
// pass in previous token
filesResult = folder.getFilesForPaging(DocsList.FileType.DOCUMENT, 3, token);
files = filesResult.getFiles();
// log the next 3 document names
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
type |
| the type of files to return |
number | Integer | the number of files to return |
token |
| the token from the previous lookup |
Return
— the requested files and paging tokenFilesResult
getFilesForPaging(number)
getFilesForPaging(number)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files in this container and a paging token.
If the requested number of files do not exist, it returns the available
files.
// Logs the first 3 file names (or less if there are fewer
// than 3 files) from the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var filesResult = folder.getFilesForPaging(3);
var files = filesResult.getFiles();
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
number | Integer | the number of files to return |
Return
— the requested files and paging tokenFilesResult
getFilesForPaging(number, token)
getFilesForPaging(number, token)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
files in this container, picking up
from where the token
from the previous lookup left off.
If the requested number of files do not exist, it returns the available
files.
// Logs the first 6 file names in the 'kittens' folder but does it 3 at
// a time.
var folder = DocsList.getFolder('kittens');
var filesResult = folder.getFilesForPaging(3);
var files = filesResult.getFiles();
var token = filesResult.getToken();
// log the first 3 file names
for (var i in files) {
Logger.log(files[i].getName());
}
filesResult = folder.getFilesForPaging(3, token); // pass in previous token
files = filesResult.getFiles();
// log the next 3 file names
for (var i in files) {
Logger.log(files[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
number | Integer | the number of files to return |
token |
| the paging token from the previous lookup |
Return
— the requested files and paging tokenFilesResult
getFolders()
getFolders()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns all the folders in this container (up to a maximum of
).
DocsList.DEFAULT_RESULT_SIZE
// Logs the number of folders in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var subFolders = folder.getFolders();
Logger.log(subFolders.length);
Return
— the requested foldersFolder[]
getFolders(start, max)
getFolders(start, max)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a subrange of the folders in this container. If there are not enough results to fill the range, a partial range will be returned.
// Logs the first 3 folder names (or less if there are fewer
// than 3 folders) in the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var subFolders = folder.getFolders(0, 3);
for (var i in subFolders) {
Logger.log(subFolders[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
start | Integer | the 0-indexed position to start returning results from |
max | Integer | the maximum number of folders to return |
Return
— the requested foldersFolder[]
getFoldersForPaging(number)
getFoldersForPaging(number)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the first number
of folders in this container and a paging token.
If the requested number of folders do not exist, it returns the available
folders.
// Logs the first 3 folder names (or less if there are fewer
// than 3 folders) from the 'kittens' folder
var folder = DocsList.getFolder('kittens');
var subFoldersResult = folder.getFoldersForPaging(3);
var subFolders = subFoldersResult.getFolders();
for (var i in subFolders) {
Logger.log(subFolders[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
number | Integer | the number of folders to return |
Return
— the requested folders and a paging tokenFoldersResult
getFoldersForPaging(number, token)
getFoldersForPaging(number, token)
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the next number
folders in this container, picking up
from where the token
from the previous lookup left off.
If the requested number of folders do not exist, it returns the available
folders.
// Logs the first 6 folder names in the 'kittens' folder but does it 3 at
// a time.
var folder = DocsList.getFolder('kittens');
var foldersResult = folder.getFoldersForPaging(3);
var subFolders = foldersResult.getFolders();
var token = foldersResult.getToken();
// log the first 3 sub folder names
for (var i in subFolders) {
Logger.log(subFolders[i].getName());
}
folderResult = folder.getAllFoldersForPaging(3, token); // pass in previous token
subFolders = foldersResult.getFolders();
// log the next 3 sub folder names
for (var i in subFolders) {
Logger.log(subFolders[i].getName());
}
Parameters
Name | Type | Description |
---|---|---|
number | Integer | the number of folders to return |
token |
| the token from the previous lookup |
Return
— the requested folders and paging tokenFoldersResult
getId()
getId()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the document ID associated with the item.
// Logs the first file's document ID.
// Note: This can also be used on a folder.
var file = DocsList.getAllFiles()[0];
Logger.log(file.getId());
Return
String
— the document ID of the item
getLastUpdated()
getLastUpdated()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the date that this item was last updated.
// This example logs the date the first file was last updated.
// Note: This can also be used on a folder
var file = DocsList.getAllFiles[0];
Logger.log(file.getLastUpdated());
Return
Date
— the date this item was last updated
getName()
getName()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the name of the item.
// Logs the first file's name.
// Note: This can also be used on a folder.
var file = DocsList.getAllFiles()[0];
Logger.log(file.getName());
Return
String
— the name of the item
getOwner()
getOwner()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the owner of the item.
// This example creates a file and logs the owner's email address
// Note: This can also be used on a folder
var file = DocsList.createFile('my test file', 'test file contents');
Logger.log(file.getOwner().getEmail()); // logs your own email address
Return
User
— the owner of the item
getParents()
getParents()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the parent folders. If called on a top level item, it returns the root folder. An item can be placed in multiple folders in drive. See the drive documentation.
// This example logs the name of the parent folder of the first doc.
// Note: This can also be used on a folder to get its parent
var file = DocsList.getFilesByType(DocsList.FileType.DOCUMENT)[0];
Logger.log(file.getParents()[0].getName());
Return
— the parent folders containing the itemFolder[]
getSize()
getSize()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns the amount of disk space used by the item. Note that it returns zero if called on an item that does not consume disk space, such as a Google document type file.
// This example logs the first file's size in bytes
// Note: This can also be used on a folder to get the size of its contents
var file = DocsList.getAllFiles[0];
Logger.log(file.getSize());
Return
Integer
— the item's size in bytes, or zero if the item is a Google document
type or does not consume space
getUrl()
getUrl()
Deprecated. This function is deprecated and should not be used in new scripts.
Returns a URL to access the particular item.
// This example logs the first file's URL
// Note: This can also be used on a folder
var file = DocsList.getAllFiles[0];
Logger.log(file.getUrl());
Return
String
— the item's URL
getViewers()
getViewers()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the list of viewers and commenters for this
. If the user who executes
the script does not have edit access to the Folder
, this method throws an exception.Folder
Return
User[]
— an array of users with view or comment permission
isStarred()
isStarred()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets whether the item is starred.
// This example creates a new file, stars it, and tests whether it is starred.
// Note: This can also be used on a folder
var file = DocsList.createFile('my test file', 'test file contents');
file.setStarred(true); // the file should be starred in drive
Logger.log(file.isStarred()); // logs true
Return
Boolean
— true if the item is starred
isTrashed()
isTrashed()
Deprecated. This function is deprecated and should not be used in new scripts.
Checks whether the item is trashed.
// This example creates a new file and then sets it trashed.
// Note: This can also be used on a folder
var file = DocsList.createFile('my test file', 'test file contents');
file.setTrashed(true); // the file should be trashed in drive
Logger.log(file.isTrashed()); // logs true
Return
Boolean
— true if the item is trashed
removeEditor(emailAddress)
removeEditor(emailAddress)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes the given user from the list of editors for the
. This method does not
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.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddress | String | the email address of the user to remove |
Return
removeEditor(user)
removeEditor(user)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes the given user from the list of editors for the
. This method does not
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.Folder
Parameters
Name | Type | Description |
---|---|---|
user | User | a representation of the user to remove |
Return
removeFromFolder(parent)
removeFromFolder(parent)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes this object from the given folder. If the item does not belong to the folder, this does nothing.
// This example creates a new file, adds it to a folder, and then removes
// it from the folder.
// Note: This can also be used on a folder to remove it from another folder
var file = DocsList.createFile('my test file', 'test file contents');
var folder = DocsList.createFolder('My Test Folder');
file.addToFolder(folder);
Logger.log(folder.getFiles().length); // logs 1
file.removeFromFolder(folder);
Logger.log(folder.getFiles().length); // logs 0
Parameters
Name | Type | Description |
---|---|---|
parent |
| the folder to remove the item from |
removeViewer(emailAddress)
removeViewer(emailAddress)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes the given user from the list of viewers and commenters for the
. This
method has no effect if the user is an editor, not a viewer or commenter. This method also does
not 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.Folder
Parameters
Name | Type | Description |
---|---|---|
emailAddress | String | the email address of the user to remove |
Return
removeViewer(user)
removeViewer(user)
Deprecated. This function is deprecated and should not be used in new scripts.
Removes the given user from the list of viewers and commenters for the
. This
method has no effect if the user is an editor, not a viewer. This method also does not 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.Folder
Parameters
Name | Type | Description |
---|---|---|
user | User | a representation of the user to remove |
Return
rename(newName)
rename(newName)
Deprecated. This function is deprecated and should not be used in new scripts.
Rename the item.
// Creates a file called 'Old File' and renames it 'New File'.
// Note: This can also be used on a folder
var oldFile = DocsList.createFile('Old File', '');
oldFile.rename('New File');
Logger.log(oldFile.getName()); // This should log "New File"
Parameters
Name | Type | Description |
---|---|---|
newName | String | the new name of the item |
setDescription(description)
setDescription(description)
Deprecated. This function is deprecated and should not be used in new scripts.
Update's the item's description.
// This example sets the first document's description
// Note: This can also be used on a folder
var doc = DocsList.getFilesByType(DocsList.FileType.DOCUMENT)[0];
doc.setDescription('My First Doc');
Logger.log(doc.getDescription()); // logs 'My First Doc'
Parameters
Name | Type | Description |
---|---|---|
description | String | the item's description |
setStarred(starred)
setStarred(starred)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the item's starred status in drive.
// This example creates a new file and stars it.
// Note: This can also be used on a folder
var file = DocsList.createFile('my test file', 'test file contents');
file.setStarred(true); // the file should be starred in drive
Parameters
Name | Type | Description |
---|---|---|
starred | Boolean | stars the item if true; unstars it if false |
setTrashed(trash)
setTrashed(trash)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the trashed status of an item but does not permanently delete it.
// This example creates a new file and then sets it trashed.
// Note: This can also be used on a folder
var file = DocsList.createFile('my test file', 'test file contents');
file.setTrashed(true); // the file should be trashed in drive
Logger.log(file.isTrashed()); // logs true
Parameters
Name | Type | Description |
---|---|---|
trash | Boolean | trashes the item if true; untrashes it if false |