我已經設置了一個谷歌驅動器文件夾結構,可以使用2級子文件夾工作。例如谷歌驅動器/電子表格 - 在子文件夾中修改文件時的電子郵件通知
主文件夾
- 面積1
---豁免區
- 面積2
---豁免區
我需要一個電子郵件通知的時間文件被修改以確保其他用戶必須獲得最新的數據。我在網上找到了一個主要工作的腳本,但我需要它能夠在子文件夾中檢查這個腳本沒有做的修改。任何幫助,將不勝感激。謝謝,阿曼達
function GoogleDriveModifiedFiles(){
// Folder ID "XXXXXXXxxXXXwwerr0RSQ2ZlZms" of the folder to monitor for changes
var folderID = '"' + "0Bwz931NfDj3HUnhTVXBuc1lqMTg" + '"';
// Email Configuration
var emailFromName ="Work Google Drive (Do Not Reply)";
var emailSubject = "Work Google Drive content has been modified";
var emailBody = "<br>You are receiving this email because a folder/file shared with you on Google Drive has been modified, click on the link to view new content<br>"
var emailFooter = "Any questions please contact [email protected]";
var folderSearch = folderID + " " + "in parents";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var email = sheet.getRange("E1").getValue();
var timezone = ss.getSpreadsheetTimeZone();
var today = new Date();
var oneDayAgo = new Date(today.getTime() - 1 * 60 * 1000);
var startTime = oneDayAgo.toISOString();
var search = '(trashed = true or trashed = false) and '+ folderSearch +' and (modifiedDate > "' + startTime + '")';
var files = DriveApp.searchFiles(search);
var row = "", count=0;
while(files.hasNext()) {
var file = files.next();
var fileName = file.getName();
var fileURL = file.getUrl();
var lastUpdated = Utilities.formatDate(file.getLastUpdated(), timezone, "dd-MM-yyyy HH:mm");
var dateCreated = Utilities.formatDate(file.getDateCreated(), timezone, "dd-MM-yyyy HH:mm")
row += "<li>" + lastUpdated + " <a href='" + fileURL + "'>" + fileName + "</a></li>";
sheet.appendRow([dateCreated, lastUpdated, fileName, fileURL]);
count++;
}
if (row !== "") {
row = "<p>" + count + " file(s) changed:</p><ol>" + row + "</ol>";
row += emailBody+"<br>" + "<br><small> "+emailFooter+" </a>.</small>";
MailApp.sendEmail(email, emailSubject, "", {name: emailFromName, htmlBody: row});
}
}