Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement