PDF模板存档

时间:2015-02-12 22:55:08

标签: google-apps-script

我创建了一个生成响应表的表单。我还创建了一个Doc,这是我的回复填写的模板。从这里开始变成PDF并通过电子邮件发送给特定的收件人。我现在需要根据列答案将这些存档到特定文件夹中。我只是想首先将它们移动或复制到特定的文件夹中。这怎么可能。我使用过多个脚本但却无法看到断开连接的位置。任何帮助将不胜感激。谢谢enter link description here

1 个答案:

答案 0 :(得分:0)

您可以尝试使用以下代码:

function moveFileToFolder() {
  var theFolder = DriveApp.getFolderById('your Folder ID');

  var theFile = DriveApp.getFileById('Your File ID').makeCopy(theFolder);

  var oldFileName = theFile.getName();

  var archivedName = oldFileName.slice(5);
  Logger.log('archivedName: ' + archivedName);

  archivedName = "archive" + archivedName;

  theFile.setName(archivedName);
}

删除旧文件而不必将其发送到垃圾箱:

//This requires the Drive API To be turned on in the Advanced Google Services. 
//RESOURCES menu, ADVANCED GOOGLE SERVICES
function deleteFile(idToDLET) {
  //idToDLET = 'the File ID';

  //This deletes a file without needing to move it to the trash
  var rtrnFromDLET = Drive.Files.remove(idToDLET);
}