【问题标题】:Overwrite File in Google Drive覆盖 Google Drive 中的文件
【发布时间】:2018-04-13 05:29:03
【问题描述】:

我正在使用这个 Google 脚本:

Gmail2GDrive

它就像一个魅力,除了我需要它来覆盖现有文件,因为我打算链接到它并分享它。

我需要如何修改这个脚本?

【问题讨论】:

  • 什么脚本?如果您正在寻求调试帮助,则需要在问题本身中包含 MCVE。
  • @tehhowch 对不起,我搞砸了链接。我更正了帖子。我正在使用的脚本在这里:github.com/ahochsteger/gmail2gdrive
  • 您遇到问题的代码应该在您的问题中 - 而不是在某些第 3 方网站上。也就是说,不要只逐字发布您的代码。我们不是来修复您的生产代码的。从您的代码构建一个 MCVE,并将其编辑到您的问题中。

标签: google-apps-script


【解决方案1】:

您无法真正覆盖 Google 云端硬盘中的文件。 (我不知道。) 每个文件都有自己唯一的 ID,这意味着文件名是无关紧要的。 (尝试覆盖 Windows 资源管理器术语中的文件时。)

话虽如此,我过去曾使用它来使用 Google App Script 移动文件。希望对您有所帮助:

  //Get the ID of the Destination Folder
  var destinationFolder = DriveApp.getFolderById("Your Folder ID");

  //Create a copy of the Merged Sheets Temp and move to the Desitnation Folder.
  DriveApp.getFileById(FileToMove.getId()).makeCopy("Give the File a name", destinationFolder);

  //Move Merged Sheets Temp to Trash
  var tempMergeDocument = DriveApp.getFileById(FileToMove.getId()).setTrashed(true)

【讨论】:

猜你喜欢
  • 2017-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-14
  • 1970-01-01
  • 2021-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多