0

我正在使用我在堆栈溢出中发现的谷歌应用程序脚本来执行基于时间的文件的每日备份。现在我删除了其中的一些文件,并从 apps-scripts-notifications@goggle.com 收到一封电子邮件,说明脚本未能成功完成。

使用此代码:

// Abhijeet Chopra
// 26 February 2016
// Google Apps Script to make copies of Google Sheet in specified destination folder

function makeCopy() {
  // generates the timestamp and stores in variable formattedDate as year-month-date hour-minute-second
  var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH:mm:ss");  
  // gets the name of the original file and appends the word "copy" followed by the timestamp stored in formattedDate
  var name = SpreadsheetApp.getActiveSpreadsheet().getName() + " Copy " + formattedDate;  
  // gets the destination folder by their ID. REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your folder's ID that you can get by opening the folder in Google Drive and checking the URL in the browser's address bar
  var destination = DriveApp.getFolderById("1ysgERhjmrnq5Uzb9Lu7CtqOWccVTHyVj");  
  // gets the current Google Sheet file
  var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId())  
  // makes copy of "file" with "name" at the "destination"
  file.makeCopy(name, destination);
}

错误消息是需要授权才能执行该操作。

由于该文件不再位于 Google Drive 上的“垃圾箱”文件夹中,因此我不知道如何关闭备份不应该存在的文件的尝试。我也找不到任何活动触发器了。

我真的很感激一些意见!谢谢。

4

0 回答 0