Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Created May 31, 2017 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save swbuehler/cbb0fc0d43a7f3a569294f1c786be03f to your computer and use it in GitHub Desktop.
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
/*
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>&mdash;' + 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