Google Apps Script

Class FoldersResult

Holds an array of folders as well as a token used to enable pagination in methods that return a limited number of items such as DocsList.getAllFoldersForPaging(number, token).

 
// This example logs the names of all folders in the users drive in batches of 5
 var pageSize = 5;
 var folders = null;
 var token = null; // using null token for the first lookup
 do {
   var result = DocsList.getAllFoldersForPaging(pageSize, token);
   folders = result.getFolders();
   token = result.getToken();
   for (var i = 0; i < folders.length; i++) {
     Logger.log(folders[i].getName());
   }
 } while (folders.length >= pageSize);
 

Methods

MethodReturn typeBrief description
getFolders()Folder[]Gets the folders contained in this result.
getToken()TokenGets the token for this result.

Detailed documentation

getFolders()

Gets the folders contained in this result.

 
// This example gets the first 3 folders and logs their names.
 var foldersResult = DocsList.getAllFoldersForPaging(3);
 var folders = foldersResult.getFolders();
 for (var i in folders) {
   Logger.log(folders[i].getName());
 }
 

Return

Folder[] — the folders in this result


getToken()

Gets the token for this result. A token is used for pagination purposes. It can be passed into functions like DocsList.getAllFoldersForPaging(number, token) to get the next set of results.

 
// This example logs the names of the first 6 folders processing 3 at a
 // time.
 var foldersResult = DocsList.getAllFoldersForPaging(3);
 var folders = foldersResult.getFolders();
 for (var i in folders) {
   Logger.log(folders[i].getName());
 }
 var token = foldersResult.getToken();
 var nextResult = DocsList.getAllFoldersForPaging(3, token);
 folders = nextResult.getFolders();
 for (var i in folders) {
   Logger.log(folders[i].getName());
 }
 

Return

Token — the token for this result, used for pagination purposes

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.