Class DriveApp

DriveApp

स्क्रिप्ट को Google Drive में फ़ाइलें और फ़ोल्डर बनाने, ढूंढने, और उनमें बदलाव करने की अनुमति देता है. शेयर की गई ड्राइव में मौजूद फ़ाइलें या फ़ोल्डर ऐक्सेस करने के लिए, Drive की बेहतर सेवा का इस्तेमाल करें.

// Logs the name of every file in the user's Drive.
var files = DriveApp.getFiles();
while (files.hasNext()) {
  var file = files.next();
  console.log(file.getName());
}

प्रॉपर्टी

प्रॉपर्टीTypeब्यौरा
AccessAccessकिसी फ़ाइल या फ़ोल्डर को ऐक्सेस करने वाले उपयोगकर्ताओं की क्लास को दिखाने वाला एनम, उन उपयोगकर्ताओं के अलावा होता है जिन्हें साफ़ तौर पर ऐक्सेस दिया गया है.
PermissionPermissionयह किसी फ़ाइल या फ़ोल्डर को ऐक्सेस करने वाले उपयोगकर्ताओं के अलावा, साफ़ तौर पर ऐक्सेस दिए गए उपयोगकर्ताओं को दी गई अनुमतियों के तौर पर दिखाया जाता है.

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
continueFileIterator(continuationToken)FileIteratorयह पिछले इटरेटर से मिले कंटिन्यूशन टोकन का इस्तेमाल करके, फ़ाइल को दोहराना फिर से शुरू करता है.
continueFolderIterator(continuationToken)FolderIteratorयह पिछले इटरेटर से मिले कंटिन्यूशन टोकन का इस्तेमाल करके, फ़ोल्डर को इटरेट करने की प्रोसेस को फिर से शुरू करता है.
createFile(blob)Fileदिए गए Blob आर्बिट्रेरी डेटा से, उपयोगकर्ता के Drive के रूट में फ़ाइल बनाता है.
createFile(name, content)Fileदिए गए नाम और कॉन्टेंट के साथ, उपयोगकर्ता के Drive के रूट में एक टेक्स्ट फ़ाइल बनाता है.
createFile(name, content, mimeType)Fileदिए गए नाम, कॉन्टेंट, और MIME टाइप वाली उपयोगकर्ता के Drive के रूट में एक फ़ाइल बनाता है.
createFolder(name)Folderदिए गए नाम से उपयोगकर्ता की Drive के रूट में फ़ोल्डर बनाता है.
createShortcut(targetId)Fileदिए गए Drive आइटम आईडी का शॉर्टकट बनाता है और उसे दिखाता है.
createShortcutForTargetIdAndResourceKey(targetId, targetResourceKey)Fileदिए गए 'Drive आइटम आईडी' और संसाधन कुंजी का शॉर्टकट बनाता है और उसे लौटाता है.
enforceSingleParent(value)voidइससे आइटम पैरंट पर असर डालने वाले सभी कॉल के लिए,AllowSingleParent के व्यवहार को चालू या बंद किया जाता है.
getFileById(id)Fileदिए गए आईडी वाली फ़ाइल को ऐक्सेस करता है.
getFileByIdAndResourceKey(id, resourceKey)Fileयह फ़ंक्शन, दिए गए आईडी और संसाधन कुंजी वाली फ़ाइल को ऐक्सेस करता है.
getFiles()FileIteratorउपयोगकर्ता के Drive में मौजूद सभी फ़ाइलों का संग्रह बनाता है.
getFilesByName(name)FileIteratorयह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का संग्रह इकट्ठा करता है जिनका नाम दिया गया है.
getFilesByType(mimeType)FileIteratorयह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का संग्रह इकट्ठा करता है जिनका MIME टाइप दिया गया है.
getFolderById(id)Folderदिए गए आईडी वाले फ़ोल्डर को ऐक्सेस करता है.
getFolderByIdAndResourceKey(id, resourceKey)Folderदिए गए आईडी और संसाधन कुंजी वाले फ़ोल्डर को ऐक्सेस करता है.
getFolders()FolderIteratorउपयोगकर्ता की Drive में मौजूद सभी फ़ोल्डर का कलेक्शन ऐक्सेस करता है.
getFoldersByName(name)FolderIteratorउपयोगकर्ता की Drive में मौजूद उन सभी फ़ोल्डर का संग्रह इकट्ठा करता है जिनका नाम दिया गया है.
getRootFolder()Folderउपयोगकर्ता के Drive के रूट में फ़ोल्डर को ऐक्सेस करता है.
getStorageLimit()Integerउपयोगकर्ता के पास Drive में कितने बाइट डेटा सेव करने की अनुमति होती है.
getStorageUsed()Integerउस बाइट की संख्या मिलती है जो उपयोगकर्ता मौजूदा समय में Drive में सेव कर रहा है.
getTrashedFiles()FileIteratorउपयोगकर्ता की Drive के ट्रैश फ़ोल्डर में मौजूद सभी फ़ाइलों का संग्रह बनाता है.
getTrashedFolders()FolderIteratorउपयोगकर्ता की Drive के ट्रैश फ़ोल्डर में मौजूद सभी फ़ोल्डर का संग्रह बनाता है.
searchFiles(params)FileIteratorइसमें, उपयोगकर्ता के Drive में उन सभी फ़ाइलों का कलेक्शन सेव होता है जो खोज की शर्तों से मेल खाती हैं.
searchFolders(params)FolderIteratorइसमें उपयोगकर्ता की Drive में मौजूद, खोज की शर्तों से मेल खाने वाले सभी फ़ोल्डर का कलेक्शन शामिल होता है.

ज़्यादा जानकारी के साथ दस्तावेज़

continueFileIterator(continuationToken)

यह पिछले इटरेटर से मिले कंटिन्यूशन टोकन का इस्तेमाल करके, फ़ाइल को दोहराना फिर से शुरू करता है. यह तरीका तब फ़ायदेमंद होता है, जब किसी इटरेटर को एक बार में प्रोसेस करने की प्रोसेस, ज़्यादा से ज़्यादा समय से ज़्यादा हो जाती है. जारी रखने के टोकन आम तौर पर एक हफ़्ते के लिए मान्य होते हैं.

// Continues getting a list of all 'Untitled document' files in the user's Drive.
// Creates a file iterator named 'previousIterator'.
const previousIterator = DriveApp.getFilesByName('Untitled document');

// Gets continuation token from the previous file iterator.
const continuationToken = previousIterator.getContinuationToken();

// Creates a new iterator using the continuation token from the previous file iterator.
const newIterator = DriveApp.continueFileIterator(continuationToken);

// Resumes the file iteration using a continuation token from 'firstIterator' and
// logs the file name.
if (newIterator.hasNext()) {
  const file = newIterator.next();
  console.log(file.getName());
}

पैरामीटर

नामTypeब्यौरा
continuationTokenStringपिछली फ़ाइल इटरेटर से मिला कॉन्टिन्यूशन टोकन.

रिटर्न

FileIterator — यह उन फ़ाइलों का कलेक्शन है जो कंटिन्यूशन टोकन जनरेट होने के दौरान, पिछले इटरेटर में सेव रहती थीं.


continueFolderIterator(continuationToken)

यह पिछले इटरेटर से मिले कंटिन्यूशन टोकन का इस्तेमाल करके, फ़ोल्डर को इटरेट करने की प्रोसेस को फिर से शुरू करता है. यह तरीका तब फ़ायदेमंद होता है, जब किसी इटरेटर को एक बार में प्रोसेस करने की प्रोसेस, ज़्यादा से ज़्यादा समय से ज़्यादा हो जाती है. जारी रखने के टोकन आम तौर पर एक हफ़्ते के लिए मान्य होते हैं.

// Continues getting a list of all folders in user's Drive.
// Creates a folder iterator named 'previousIterator'.
const previousIterator = DriveApp.getFolders();

// Gets continuation token from the previous folder iterator.
const continuationToken = previousIterator.getContinuationToken();

// Creates a new iterator using the continuation token from the previous folder iterator.
const newIterator = DriveApp.continueFolderIterator(continuationToken);

// Resumes the folder iteration using a continuation token from the previous iterator and logs
// the folder name.
if (newIterator.hasNext()) {
  const folder = newIterator.next();
  console.log(folder.getName());
}

पैरामीटर

नामTypeब्यौरा
continuationTokenStringपिछले फ़ोल्डर के इटरेटर पर मौजूद कंटिन्यूशन टोकन.

रिटर्न

FolderIterator — यह फ़ोल्डर का एक कलेक्शन है, जो कॉन्टिन्यूशन टोकन जनरेट होने के दौरान, पिछले इटरेटर में मौजूद रहा.


createFile(blob)

दिए गए Blob आर्बिट्रेरी डेटा से, उपयोगकर्ता के Drive के रूट में फ़ाइल बनाता है.

// Create an image file in Google Drive using the Maps service.
var blob = Maps.newStaticMap().setCenter('76 9th Avenue, New York NY').getBlob();
DriveApp.createFile(blob);

पैरामीटर

नामTypeब्यौरा
blobBlobSourceनई फ़ाइल के लिए डेटा.

रिटर्न

File — नई फ़ाइल.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

createFile(name, content)

दिए गए नाम और कॉन्टेंट के साथ, उपयोगकर्ता के Drive के रूट में एक टेक्स्ट फ़ाइल बनाता है. अगर content 50 एमबी से बड़ा है, तो यह अपवाद है.

// Create a text file with the content "Hello, world!"
DriveApp.createFile('New Text File', 'Hello, world!');

पैरामीटर

नामTypeब्यौरा
nameStringनई फ़ाइल का नाम.
contentStringनई फ़ाइल का कॉन्टेंट.

रिटर्न

File — नई फ़ाइल.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

createFile(name, content, mimeType)

दिए गए नाम, कॉन्टेंट, और MIME टाइप वाली उपयोगकर्ता के Drive के रूट में एक फ़ाइल बनाता है. content 10 एमबी से बड़ा होने पर एक अपवाद देता है.

// Create an HTML file with the content "Hello, world!"
DriveApp.createFile('New HTML File', '<b>Hello, world!</b>', MimeType.HTML);

पैरामीटर

नामTypeब्यौरा
nameStringनई फ़ाइल का नाम.
contentStringनई फ़ाइल का कॉन्टेंट.
mimeTypeStringनई फ़ाइल का MIME टाइप.

रिटर्न

File — नई फ़ाइल.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

createFolder(name)

दिए गए नाम से उपयोगकर्ता की Drive के रूट में फ़ोल्डर बनाता है.

पैरामीटर

नामTypeब्यौरा
nameStringनए फ़ोल्डर का नाम.

रिटर्न

Folder — नया फ़ोल्डर.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

createShortcut(targetId)

दिए गए Drive आइटम आईडी का शॉर्टकट बनाता है और उसे दिखाता है.

पैरामीटर

नामTypeब्यौरा
targetIdStringटारगेट फ़ाइल या फ़ोल्डर का फ़ाइल आईडी.

रिटर्न

File — नया शॉर्टकट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

createShortcutForTargetIdAndResourceKey(targetId, targetResourceKey)

दिए गए 'Drive आइटम आईडी' और संसाधन कुंजी का शॉर्टकट बनाता है और उसे लौटाता है. संसाधन कुंजी एक अतिरिक्त पैरामीटर है. इसे लिंक की मदद से शेयर की गई टारगेट फ़ाइल या फ़ोल्डर को ऐक्सेस करने के लिए भेजना पड़ता है.

// Creates shortcuts for all folders in the user's drive that have a specific name.
// TODO(developer): Replace 'Test-Folder' with a valid folder name in your drive.
const folders = DriveApp.getFoldersByName('Test-Folder');

// Iterates through all folders named 'Test-Folder'.
while (folders.hasNext()) {
  const folder = folders.next();

  // Creates a shortcut to the provided Drive item ID and resource key, and returns it.
  DriveApp.createShortcutForTargetIdAndResourceKey(folder.getId(), folder.getResourceKey());
}

पैरामीटर

नामTypeब्यौरा
targetIdStringटारगेट फ़ाइल या फ़ोल्डर का आईडी.
targetResourceKeyStringटारगेट फ़ाइल या फ़ोल्डर की संसाधन कुंजी.

रिटर्न

File — नया शॉर्टकट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

enforceSingleParent(value)

इससे आइटम पैरंट पर असर डालने वाले सभी कॉल के लिए,AllowSingleParent के व्यवहार को चालू या बंद किया जाता है.

ज़्यादा जानकारी के लिए, Google Drive के फ़ोल्डर के स्ट्रक्चर और शेयर करने के मॉडल को आसान बनाना ब्लॉग देखें.

// Enables enforceSingleParent behavior for all calls affecting item parents.
DriveApp.enforceSingleParent(true);

पैरामीटर

नामTypeब्यौरा
valueBooleanecommerceSingleParent फ़्लैग की नई स्थिति.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive

getFileById(id)

दिए गए आईडी वाली फ़ाइल को ऐक्सेस करता है. अगर फ़ाइल मौजूद नहीं है या उपयोगकर्ता को उसे ऐक्सेस करने की अनुमति नहीं है, तो यह स्क्रिप्टिंग अपवाद को फेंकता है.

// Gets a list of all files in Google Drive with the given name.
// TODO(developer): Replace 'Test' with your file name.
const files = DriveApp.getFilesByName('Test');

if (files.hasNext()) {
  // Gets the ID of each file in the list.
  const fileId = files.next().getId();

  // Gets the file name using its ID and logs it to the console.
  console.log(DriveApp.getFileById(fileId).getName());
}

पैरामीटर

नामTypeब्यौरा
idStringफ़ाइल का आईडी.

रिटर्न

File — दिए गए आईडी वाली फ़ाइल.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFileByIdAndResourceKey(id, resourceKey)

यह फ़ंक्शन, दिए गए आईडी और संसाधन कुंजी वाली फ़ाइल को ऐक्सेस करता है. संसाधन कुंजियां ऐसे अतिरिक्त पैरामीटर हैं जिन्हें लिंक का इस्तेमाल करके शेयर की गई फ़ाइलों को ऐक्सेस करने के लिए भेजना पड़ता है.

अगर फ़ाइल मौजूद नहीं है या उपयोगकर्ता को उसे ऐक्सेस करने की अनुमति नहीं है, तो यह स्क्रिप्टिंग अपवाद का इस्तेमाल करता है.

// Gets a list of all files in Drive with the given name.
// TODO(developer): Replace 'Test' with your file name.
const files = DriveApp.getFilesByName('Test');
if (files.hasNext()) {

  // Gets the first file in the list.
  const file = files.next();

  // Gets the ID and resource key.
  const key = file.getResourceKey();
  const id = file.getId();

  // Logs the file name to the console using its ID and resource key.
  console.log(DriveApp.getFileByIdAndResourceKey(id, key).getName());
}

पैरामीटर

नामTypeब्यौरा
idStringफ़ाइल का आईडी.
resourceKeyStringफ़ोल्डर की संसाधन कुंजी.

रिटर्न

File — दिए गए आईडी वाली फ़ाइल.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFiles()

उपयोगकर्ता के Drive में मौजूद सभी फ़ाइलों का संग्रह बनाता है.

रिटर्न

FileIterator — उपयोगकर्ता के Drive में मौजूद सभी फ़ाइलों का कलेक्शन.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFilesByName(name)

यह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का संग्रह इकट्ठा करता है जिनका नाम दिया गया है.

पैरामीटर

नामTypeब्यौरा
nameStringढूंढने के लिए फ़ाइलों के नाम.

रिटर्न

FileIterator — उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का कलेक्शन जिनका नाम दिया गया है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFilesByType(mimeType)

यह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का संग्रह इकट्ठा करता है जिनका MIME टाइप दिया गया है.

पैरामीटर

नामTypeब्यौरा
mimeTypeStringढूंढी जाने वाली फ़ाइलों का MIME टाइप.

रिटर्न

FileIterator — यह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का कलेक्शन है जिनका MIME टाइप दिया गया है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFolderById(id)

दिए गए आईडी वाले फ़ोल्डर को ऐक्सेस करता है. अगर फ़ोल्डर मौजूद नहीं है या उपयोगकर्ता के पास उसे ऐक्सेस करने की अनुमति नहीं है, तो स्क्रिप्टिंग अपवाद लगाता है.

पैरामीटर

नामTypeब्यौरा
idStringफ़ोल्डर का आईडी.

रिटर्न

Folder — दिए गए आईडी वाला फ़ोल्डर.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFolderByIdAndResourceKey(id, resourceKey)

दिए गए आईडी और संसाधन कुंजी वाले फ़ोल्डर को ऐक्सेस करता है. संसाधन कुंजियां एक अतिरिक्त पैरामीटर हैं, जिन्हें लिंक का इस्तेमाल करके शेयर किए गए फ़ोल्डर को ऐक्सेस करना होता है.

अगर फ़ोल्डर मौजूद नहीं है या उपयोगकर्ता को उसे ऐक्सेस करने की अनुमति नहीं है, तो स्क्रिप्टिंग अपवाद लगाता है.

पैरामीटर

नामTypeब्यौरा
idStringफ़ोल्डर का आईडी.
resourceKeyStringफ़ोल्डर की संसाधन कुंजी.

रिटर्न

Folder — दिए गए आईडी वाला फ़ोल्डर.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFolders()

उपयोगकर्ता की Drive में मौजूद सभी फ़ोल्डर का कलेक्शन ऐक्सेस करता है.

रिटर्न

FolderIterator — यह उपयोगकर्ता की Drive में मौजूद सभी फ़ोल्डर का कलेक्शन होता है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getFoldersByName(name)

उपयोगकर्ता की Drive में मौजूद उन सभी फ़ोल्डर का संग्रह इकट्ठा करता है जिनका नाम दिया गया है.

पैरामीटर

नामTypeब्यौरा
nameStringढूंढने के लिए फ़ोल्डर का नाम.

रिटर्न

FolderIterator — उपयोगकर्ता के Drive में मौजूद उन सभी फ़ोल्डर का कलेक्शन जिनका नाम दिया गया है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getRootFolder()

उपयोगकर्ता के Drive के रूट में फ़ोल्डर को ऐक्सेस करता है.

// Gets the user's My Drive folder and logs its name to the console.
console.log(DriveApp.getRootFolder().getName());

// Logs the Drive owner's name to the console.
console.log(DriveApp.getRootFolder().getOwner().getName());

रिटर्न

Folder — उपयोगकर्ता के Drive का रूट फ़ोल्डर.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getStorageLimit()

उपयोगकर्ता के पास Drive में कितने बाइट डेटा सेव करने की अनुमति होती है.

// Gets the number of bytes the user can store in Drive and logs it to the console.
console.log(DriveApp.getStorageLimit());

रिटर्न

Integer — बाइट की संख्या जो उपयोगकर्ता Drive में सेव कर सकता है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getStorageUsed()

उस बाइट की संख्या मिलती है जो उपयोगकर्ता मौजूदा समय में Drive में सेव कर रहा है.

// Gets the number of bytes the user is currently storing in Drive and logs it to the console.
console.log(DriveApp.getStorageUsed());

रिटर्न

Integer — उपयोगकर्ता की ओर से फ़िलहाल Drive में सेव की जा रही बाइट की संख्या.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getTrashedFiles()

उपयोगकर्ता की Drive के ट्रैश फ़ोल्डर में मौजूद सभी फ़ाइलों का संग्रह बनाता है.

// Gets a list of all the files in the trash of the user's Drive.
const trashFiles = DriveApp.getTrashedFiles();

// Logs the trash file names to the console.
while (trashFiles.hasNext()) {
  const file = trashFiles.next();
  console.log(file.getName());
}

रिटर्न

FileIterator — ट्रैश में मौजूद फ़ाइलों का संग्रह.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

getTrashedFolders()

उपयोगकर्ता की Drive के ट्रैश फ़ोल्डर में मौजूद सभी फ़ोल्डर का संग्रह बनाता है.

// Gets a collection of all the folders in the trash of the user's Drive.
const trashFolders = DriveApp.getTrashedFolders();

// Logs the trash folder names to the console.
while (trashFolders.hasNext()) {
  const folder = trashFolders.next();
  console.log(folder.getName());
}

रिटर्न

FolderIterator — ट्रैश में मौजूद फ़ोल्डर का संग्रह.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

searchFiles(params)

इसमें, उपयोगकर्ता के Drive में उन सभी फ़ाइलों का कलेक्शन सेव होता है जो खोज की शर्तों से मेल खाती हैं. खोज के लिए ज़रूरी शर्तें, Google Drive SDK टूल से जुड़े दस्तावेज़ में दी गई हैं. ध्यान दें कि Drive सेवा, Drive API के v2 वर्शन का इस्तेमाल करती है और कुछ क्वेरी फ़ील्ड, v3 से अलग होते हैं. v2 और v3 के बीच फ़ील्ड अंतर देखें.

params आर्ग्युमेंट, एक क्वेरी स्ट्रिंग होती है. इसमें स्ट्रिंग वैल्यू हो सकती हैं. इसलिए, ध्यान रखें कि कोटेशन मार्क को सही तरीके से एस्केप किया जाए, जैसे कि "title contains 'Gulliver\\'s Travels'" या 'title contains "Gulliver\'s Travels"'.

// Logs the name of every file in the user's Drive that modified after February 28,
// 2022 whose name contains "untitled.""
var files = DriveApp.searchFiles(
    'modifiedDate > "2022-02-28" and title contains "untitled"');
while (files.hasNext()) {
  var file = files.next();
  console.log(file.getName());
}

पैरामीटर

नामTypeब्यौरा
paramsStringखोज की शर्तें, जैसा कि Google Drive SDK टूल के दस्तावेज़ में बताया गया है.

रिटर्न

FileIterator — यह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ाइलों का कलेक्शन होता है जो खोज के लिए ज़रूरी शर्तों से मेल खाती हैं.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

searchFolders(params)

इसमें उपयोगकर्ता की Drive में मौजूद, खोज की शर्तों से मेल खाने वाले सभी फ़ोल्डर का कलेक्शन शामिल होता है. खोज के लिए ज़रूरी शर्तें, Google Drive SDK टूल से जुड़े दस्तावेज़ में दी गई हैं. ध्यान दें कि Drive सेवा, Drive API के v2 वर्शन का इस्तेमाल करती है और कुछ क्वेरी फ़ील्ड, v3 से अलग होते हैं. v2 और v3 के बीच फ़ील्ड अंतर देखें.

params आर्ग्युमेंट, एक क्वेरी स्ट्रिंग होती है. इसमें स्ट्रिंग वैल्यू हो सकती हैं. इसलिए, ध्यान रखें कि कोटेशन मार्क को सही तरीके से एस्केप किया जाए, जैसे कि "title contains 'Gulliver\\'s Travels'" या 'title contains "Gulliver\'s Travels"'.

// Logs the name of every folder in the user's Drive that you own and is starred.
var folders = DriveApp.searchFolders('starred = true and "me" in owners');
while (folders.hasNext()) {
  var folder = folders.next();
  console.log(folder.getName());
}

पैरामीटर

नामTypeब्यौरा
paramsStringखोज की शर्तें, जैसा कि Google Drive SDK टूल के दस्तावेज़ में बताया गया है.

रिटर्न

FolderIterator — यह उपयोगकर्ता के Drive में मौजूद उन सभी फ़ोल्डर का कलेक्शन होता है जो खोज के लिए ज़रूरी शर्तों से मेल खाते हैं.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:

  • https://www.googleapis.com/auth/drive.readonly
  • https://www.googleapis.com/auth/drive

काम न करने वाले तरीके