खोज…


टिप्पणियों

Google Mime प्रकारों का उपयोग Mime प्रकारों के तीसरे पैरामीटर के लिए नहीं किया जा सकता है। Google Mime प्रकार का उपयोग करने पर एक त्रुटि होगी जो बताता है:

Google MIME प्रकार बनाने के लिए "DriveApp.createFile ()" का उपयोग नहीं कर सकते। कृपया उन्नत ड्राइव सेवा का उपयोग करें

MimeType.GOOGLE_APPS_SCRIPT

MimeType.GOOGLE_DOCS

MimeType.GOOGLE_DRAWINGS

MimeType.GOOGLE_FORMS

MimeType.GOOGLE_SHEETS

MimeType.GOOGLE_SLIDES

Google रूट ड्राइव में एक नया फ़ोल्डर बनाएँ

function createNewFolderInGoogleDrive() {
  var folderName,newFolder;//Declare variable names
  
  folderName = "Test Folder " + new Date().toString().slice(0,15);//Create a new folder name with date on end
  newFolder = DriveApp.createFolder(folderName);//Create a new folder in the root drive
};

एक निश्चित माइम प्रकार के Google ड्राइव में नई फ़ाइल बनाएँ

function createGoogleDriveFileOfMimeType() {
  var content,fileName,newFile;//Declare variable names
  
  fileName = "Test File " + new Date().toString().slice(0,15);//Create a new file name with date on end
  content = "This is the file Content";

  newFile = DriveApp.createFile(fileName,content,MimeType.JAVASCRIPT);//Create a new file in the root folder
};

Google रूट ड्राइव फ़ोल्डर में एक नई टेक्स्ट फ़ाइल बनाएं

function createGoogleDriveTextFile() {
  var content,fileName,newFile;//Declare variable names
  
  fileName = "Test Doc " + new Date().toString().slice(0,15);//Create a new file name with date on end
  content = "This is the file Content";

  newFile = DriveApp.createFile(fileName,content);//Create a new text file in the root folder
};

एक बूँद से Google ड्राइव में एक नई फ़ाइल बनाएँ

function createGoogleDriveFileWithBlob() {
  var blob,character,data,fileName,i,L,max,min,newFile,randomNmbr;//Declare variable names
  
  fileName = "Test Blob " + new Date().toString().slice(0,15);//Create a new file name with date on end
  
  L = 500;//Define how many times to loop
  data = "";
  max = 126;
  min = 55;

  for (i=0;i<L;i+=1) {//Loop to create data
    randomNmbr = Math.floor(Math.random()*(max-min+1)+min);//Create a random number
    //Logger.log('randomNmbr: ' + randomNmbr);
    character = String.fromCharCode(randomNmbr);
    
    //Logger.log('character: ' + character);//Print the character to the Logs
    data = data + character;
  };

  blob = Utilities.newBlob(data, MimeType.PLAIN_TEXT, fileName);//Create a blob with random characters

  newFile = DriveApp.createFile(blob);//Create a new file from a blob
  
  newFile.setName(fileName);//Set the file name of the new file
};

सभी फ़ोल्डर्स प्राप्त करें - एक निरंतर टोकन में फ़ोल्डर डालें - फिर टोकन से पुनर्प्राप्त करें

function processGoogleDriveFolders() {
  var arrayAllFolderNames,continuationToken,folders,foldersFromToken,thisFolder;//Declare variable names
  
  arrayAllFolderNames = [];//Create an empty array and assign it to this variable name
  
  folders = DriveApp.getFolders();//Get all folders from Google Drive in this account
  continuationToken = folders.getContinuationToken();//Get the continuation token

  Utilities.sleep(18000);//Pause the code for 3 seconds
  
  foldersFromToken = DriveApp.continueFolderIterator(continuationToken);//Get the original folders stored in the token
  folders = null;//Delete the folders that were stored in the original variable, to prove that the continuation token is working
  
  while (foldersFromToken.hasNext()) {//If there is a next folder, then continue looping
    thisFolder = foldersFromToken.next();//Get the next folder
    arrayAllFolderNames.push(thisFolder.getName());//Get the name of the next folder
  };
  
  Logger.log(arrayAllFolderNames);//print the folder names to the Logs
};

सभी फाइलें प्राप्त करें - उन्हें एक निरंतर टोकन में रखें - फिर उन्हें पुनर्प्राप्त करें

function processGoogleDriveFiles() {
  var arrayAllFileNames,continuationToken,files,filesFromToken,fileIterator,thisFile;//Declare variable names
  
  arrayAllFileNames = [];//Create an empty array and assign it to this variable name
  
  files = DriveApp.getFiles();//Get all files from Google Drive in this account
  continuationToken = files.getContinuationToken();//Get the continuation token
  
  Utilities.sleep(18000);//Pause the code for 3 seconds
  
  filesFromToken = DriveApp.continueFileIterator(continuationToken);//Get the original files stored in the token
  files = null;//Delete the files that were stored in the original variable, to prove that the continuation token is working
  
  while (filesFromToken.hasNext()) {//If there is a next file, then continue looping
    thisFile = filesFromToken.next();//Get the next file
    arrayAllFileNames.push(thisFile.getName());//Get the name of the next file
  };
  
  Logger.log(arrayAllFileNames);  
};


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow