Stay organized with collections Save and categorize content based on your preferences.
FileIteratorAn iterator that allows scripts to iterate over a potentially large collection of files. File iterators can be accessed from DriveApp
or a Folder
.
// Log the name of every file in the user's Drive. const files = DriveApp.getFiles(); while (files.hasNext()) { const file = files.next(); Logger.log(file.getName()); }Methods Method Return type Brief description
getContinuationToken()
String
Gets a token that can be used to resume this iteration at a later time. hasNext()
Boolean
Determines whether calling next()
will return an item. next()
File
Gets the next item in the collection of files or folders. Detailed documentation getContinuationToken()
Gets a token that can be used to resume this iteration at a later time. This method is useful if processing an iterator in one execution would exceed the maximum execution time. Continuation tokens are generally valid for one week.
ReturnString
— a continuation token that can be used to resume this iteration with the items that remained in the iterator when the token was generated
hasNext()
Determines whether calling next()
will return an item.
Boolean
— true
if next()
will return an item; false
if not
next()
Gets the next item in the collection of files or folders. Throws an exception if no items remain.
ReturnFile
— the next item in the collection
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-02 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-02 UTC."],[[["FileIterator allows scripts to iterate over a large collection of files within Google Drive, accessible via `DriveApp` or a `Folder`."],["It provides methods to check for more files (`hasNext()`), retrieve the next file (`next()`), and manage long iterations with continuation tokens (`getContinuationToken()`)."],["`getContinuationToken()` helps to resume iterations that might exceed execution time limits, with tokens typically valid for a week."],["`hasNext()` returns `true` if there are more files to iterate, allowing scripts to control the loop."],["`next()` retrieves the subsequent file in the collection, throwing an exception if none remain."]]],[]]
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