Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Get any Google Docs in folder and add a paragraph to all of them
- function example81() {
- const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');
- const listOfDocs = parentFolder.getFilesByType(MimeType.GOOGLE_DOCS);
- while (listOfDocs.hasNext()) {
- var file = listOfDocs.next();
- var docId = file.getId();
- var doc = DocumentApp.openById(docId);
- var body = doc.getBody();
- body.appendParagraph("This paragraph was added automatically.");
- }
- }
- //Delete files of a specific type that haven't been updated for over a week
- function example82() {
- const parentFolder = DriveApp.getFolderById('ADD FOLDER ID HERE');
- const listOfSsheets = parentFolder.getFilesByType(MimeType.GOOGLE_SHEETS);
- while (listOfSsheets.hasNext()) {
- var file = listOfSsheets.next();
- if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) {
- file.setTrashed(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement