Class FolderIterator
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Iterator پوشه یک شی که به اسکریپت ها اجازه می دهد تا روی مجموعه بزرگی از پوشه ها تکرار شوند. تکرارکنندههای پوشه را میتوان از Drive App
، یک File
یا یک Folder
دسترسی داشت.
// Log the name of every folder in the user's Drive.
const folders = DriveApp.getFolders();
while (folders.hasNext()) {
const folder = folders.next();
Logger.log(folder.getName());
}
روش ها
روش | نوع برگشت | شرح مختصر |
---|
get Continuation Token() | String | رمزی دریافت می کند که می تواند برای از سرگیری این تکرار در زمان دیگری استفاده شود. |
has Next() | Boolean | تعیین می کند که آیا فراخوانی next() یک آیتم را برمی گرداند یا خیر. |
next() | Folder | مورد بعدی را در مجموعه فایل ها یا پوشه ها دریافت می کند. |
مستندات دقیق
get Continuation Token()
رمزی دریافت می کند که می تواند برای از سرگیری این تکرار در زمان دیگری استفاده شود. این روش در صورتی مفید است که پردازش یک تکرار کننده در یک اجرا از حداکثر زمان اجرا تجاوز کند. توکنهای ادامه معمولاً یک هفته معتبر هستند.
بازگشت
String
- یک نشانه ادامه که می تواند برای از سرگیری این تکرار با مواردی که در زمان تولید توکن در تکرار کننده باقی مانده اند استفاده شود.
has Next()
تعیین می کند که آیا فراخوانی next()
یک آیتم را برمی گرداند یا خیر.
بازگشت
Boolean
- true
if next()
یک آیتم را برمی گرداند. false
اگر نه
next()
مورد بعدی را در مجموعه فایل ها یا پوشه ها دریافت می کند. در صورتی که هیچ موردی باقی نماند یک استثنا می اندازد.
بازگشت
Folder
- مورد بعدی در مجموعه
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eFolderIterator\u003c/code\u003e enables scripts to iterate through a large collection of folders within Google Drive.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003ehasNext()\u003c/code\u003e to check for more folders, \u003ccode\u003enext()\u003c/code\u003e to retrieve the next folder, and \u003ccode\u003egetContinuationToken()\u003c/code\u003e for handling lengthy iterations.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize \u003ccode\u003eFolderIterator\u003c/code\u003e with \u003ccode\u003eDriveApp\u003c/code\u003e, \u003ccode\u003eFile\u003c/code\u003e, or \u003ccode\u003eFolder\u003c/code\u003e objects to access and process folders programmatically.\u003c/p\u003e\n"]]],["FolderIterator allows iterating over a large collection of folders. Key actions include using `hasNext()` to check for the next item and `next()` to retrieve it. `getContinuationToken()` provides a token to resume iteration later, helpful for large collections. The example shows how to log every folder's name in a user's Drive, demonstrating iteration through the folder collection. The iterator returns folder objects and can throw an exception if no items remain.\n"],null,["# Class FolderIterator\n\nFolderIterator\n\nAn object that allows scripts to iterate over a potentially large collection of folders. Folder\niterators can be accessed from [DriveApp](/apps-script/reference/drive/drive-app), a [File](/apps-script/reference/drive/file), or a [Folder](/apps-script/reference/drive/folder).\n\n```javascript\n// Log the name of every folder in the user's Drive.\nconst folders = DriveApp.getFolders();\nwhile (folders.hasNext()) {\n const folder = folders.next();\n Logger.log(folder.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()) | [Folder](/apps-script/reference/drive/folder) | 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[Folder](/apps-script/reference/drive/folder) --- the next item in the collection"]]