Class FileIterator
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
फ़ाइलइटरेटर
एक ऐसा आइटरेटर जो स्क्रिप्ट को फ़ाइलों के बड़े कलेक्शन पर बार-बार इस्तेमाल करने की अनुमति देता है. फ़ाइल के iterator को DriveApp
या 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());
}
तरीके
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
getContinuationToken() | String | एक टोकन मिलता है, जिसका इस्तेमाल बाद में इस प्रोसेस को फिर से शुरू करने के लिए किया जा सकता है. |
hasNext() | Boolean | यह तय करता है कि next() को कॉल करने पर, कोई आइटम वापस मिलेगा या नहीं. |
next() | File | फ़ाइलों या फ़ोल्डर के कलेक्शन में अगला आइटम दिखाता है. |
ज़्यादा जानकारी वाला दस्तावेज़
getContinuationToken()
एक टोकन मिलता है, जिसका इस्तेमाल बाद में इस प्रोसेस को फिर से शुरू करने के लिए किया जा सकता है. यह तरीका तब काम आता है, जब एक बार में किसी इटरेटटर को प्रोसेस करने में, प्रोसेस करने के लिए तय किया गया ज़्यादा से ज़्यादा समय खत्म हो जाता है.
आम तौर पर, कंटिन्यूएशन टोकन एक हफ़्ते के लिए मान्य होते हैं.
वापसी का टिकट
String
— यह एक ऐसा टोकन है जिसका इस्तेमाल, टोकन जनरेट होने के बाद, उन आइटम के साथ इस दोहराव को फिर से शुरू करने के लिए किया जा सकता है जो इटरेटर में बचे थे
hasNext()
यह तय करता है कि next()
को कॉल करने पर, कोई आइटम वापस मिलेगा या नहीं.
वापसी का टिकट
Boolean
— true
, अगर next()
कोई आइटम लौटाएगा; false
, अगर नहीं
next()
फ़ाइलों या फ़ोल्डर के कलेक्शन में अगला आइटम दिखाता है. अगर कोई आइटम नहीं है, तो अपवाद दिखाता है.
वापसी का टिकट
File
— कलेक्शन में अगला आइटम
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eFileIterator allows scripts to iterate over a large collection of files within Google Drive, accessible via \u003ccode\u003eDriveApp\u003c/code\u003e or a \u003ccode\u003eFolder\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to check for more files (\u003ccode\u003ehasNext()\u003c/code\u003e), retrieve the next file (\u003ccode\u003enext()\u003c/code\u003e), and manage long iterations with continuation tokens (\u003ccode\u003egetContinuationToken()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetContinuationToken()\u003c/code\u003e helps to resume iterations that might exceed execution time limits, with tokens typically valid for a week.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ehasNext()\u003c/code\u003e returns \u003ccode\u003etrue\u003c/code\u003e if there are more files to iterate, allowing scripts to control the loop.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003enext()\u003c/code\u003e retrieves the subsequent file in the collection, throwing an exception if none remain.\u003c/p\u003e\n"]]],[],null,["# Class FileIterator\n\nFileIterator\n\nAn iterator that allows scripts to iterate over a potentially large collection of files. File\niterators can be accessed from [DriveApp](/apps-script/reference/drive/drive-app) or a [Folder](/apps-script/reference/drive/folder).\n\n```javascript\n// Log the name of every file in the user's Drive.\nconst files = DriveApp.getFiles();\nwhile (files.hasNext()) {\n const file = files.next();\n Logger.log(file.getName());\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------|-------------------------------------------|-------------------------------------------------------------------------|\n| [getContinuationToken()](#getContinuationToken()) | `String` | Gets a token that can be used to resume this iteration at a later time. |\n| [hasNext()](#hasNext()) | `Boolean` | Determines whether calling [next()](#next()) will return an item. |\n| [next()](#next()) | [File](/apps-script/reference/drive/file) | Gets the next item in the collection of files or folders. |\n\nDetailed documentation\n----------------------\n\n### `get``Continuation``Token()`\n\nGets a token that can be used to resume this iteration at a later time. This method is useful\nif processing an iterator in one execution would exceed the maximum execution time.\nContinuation tokens are generally valid for one week.\n\n#### Return\n\n\n`String` --- a continuation token that can be used to resume this iteration with the items that\nremained in the iterator when the token was generated\n\n*** ** * ** ***\n\n### `has``Next()`\n\nDetermines whether calling [next()](#next()) will return an item.\n\n#### Return\n\n\n`Boolean` --- `true` if [next()](#next()) will return an item; `false` if not\n\n*** ** * ** ***\n\n### `next()`\n\nGets the next item in the collection of files or folders. Throws an exception if no items\nremain.\n\n#### Return\n\n\n[File](/apps-script/reference/drive/file) --- the next item in the collection"]]