Created
May 31, 2017 20:48
-
-
Save swbuehler/cbb0fc0d43a7f3a569294f1c786be03f to your computer and use it in GitHub Desktop.
Email yourself a daily log of updates to your Google Drive (Google Apps Script, requires
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Requires the Moment.js library (Resources > Libraries > 15hgNOjKHUG4UtyZl9clqBbl23sDvWMS8pfDJOyIapZk5RBqwL3i-rlCo). Use the latest version. | |
*/ | |
function myFunction() { | |
var moment = Moment.load(); | |
var theHTML = ''; | |
var yesterday = moment().startOf('day').subtract(1,'days').format(); | |
var today = moment().startOf('day').format(); | |
var drive = DriveApp.searchFiles('modifiedDate >= "' + yesterday + '" and modifiedDate < "' + today + '"'); | |
theHTML = '<html><p>The following files were updated on Google Drive yesterday, ' + moment(yesterday).format('MMMM D, YYYY') + ':</p><ul>'; | |
while (drive.hasNext()){ | |
thisFile = drive.next(); | |
theHTML += '<li><a href="' + thisFile.getUrl() + '">' + thisFile.getId() + '</a>—' + thisFile.getName() + '</li>'; | |
} | |
theHTML += '</ul></html>'; | |
MailApp.sendEmail('***YOUR EMAIL ADDRESS HERE***', 'Google Drive Updates', null, { htmlBody : theHTML}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment