function deleteMyBAKs(){
var ThirtyDaysBeforeNow = new Date().getTime()-3600*1000*24*30 ;// 30 is the number of days
var files = DriveApp.getFiles();
while (files.hasNext()) {
var file = files.next();
if(file.getName().toLowerCase().match('.bak')=='.bak' && file.getDateCreated().getTime()<ThirtyDaysBeforeNow){
try{file.setTrashed(true);}
catch(e){Logger.log("Unable to Trash: "+file.getName()) }
Logger.log(file.getName()+' created on'+Utilities.formatDate(file.getDateCreated(), 'GMT','MMM-dd-yyyy'));
}
}
MailApp.sendEmail('email@address.co.uk', 'Script AUTODELETE BAK report', Logger.getLog());
}
答案 0 :(得分:1)
setTrashed方法仅适用于您是实际所有者的文件。它可能不适用于共享文档。