SHARE
TWEET

Untitled

a guest Jul 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Get any Google Docs in folder and add a paragraph to all of them
  2. function example81() {
  3.   const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');  
  4.   const listOfDocs = parentFolder.getFilesByType(MimeType.GOOGLE_DOCS);
  5.   while (listOfDocs.hasNext()) {
  6.     var file = listOfDocs.next();
  7.     var docId = file.getId();
  8.     var doc = DocumentApp.openById(docId);
  9.     var body = doc.getBody();
  10.     body.appendParagraph("This paragraph was added automatically.");
  11.   }
  12. }
  13.  
  14. //Delete files of a specific type that haven't been updated for over a week
  15. function example82() {
  16.   const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');  
  17.   const listOfSsheets = parentFolder.getFilesByType(MimeType.GOOGLE_SHEETS);  
  18.   while (listOfSsheets.hasNext()) {  
  19.     var file = listOfSsheets.next();  
  20.     if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) {
  21.      file.setTrashed(true);
  22.     }
  23.   }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top