Google Apps Script

Class FilesResult

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

 
// This example logs the names of all files in the user's drive in batches of 200.
 var pageSize = 200;
 var files = null;
 var token = null; // use a null token for the first lookup
 do {
   var result = DocsList.getAllFilesForPaging(pageSize, token);
   files = result.getFiles();
   token = result.getToken();
   for (var i = 0; i < files.length; i++) {
     Logger.log(files[i].getName());
   }
 } while (files.length >= pageSize);
 

Methods

MethodReturn typeBrief description
getFiles()File[]Gets the files contained in this result.
getToken()TokenGets the token for this result.

Detailed documentation

getFiles()

Gets the files contained in this result.

 
// This example gets the first five files and logs their names.
 var filesResult = DocsList.getAllFilesForPaging(5);
 var files = filesResult.getFiles();
 for (var i in files) {
   Logger.log(files[i].getName());
 }
 

Return

File[] — the files 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.getAllFilesForPaging(number, token) to get the next set of results.

 
// This example logs the names of the first 10 files processing 5 at a
 // time.
 var filesResult = DocsList.getAllFilesForPaging(5);
 var files = filesResult.getFiles();
 // log first 5 file names
 for (var i in files) {
   Logger.log(files[i].getName());
 }
 var token = filesResult.getToken();
 var nextResult = DocsList.getAllFilesForPaging(5, token);
 files = nextResult.getFiles();
 // log remaining 5 file names
 for (var i in files) {
   Logger.log(files[i].getName());
 }
 

Return

Token — the token for this result, useful 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.