【问题标题】:How to copy contents of one script file and replace the contents of another script file?如何复制一个脚本文件的内容并替换另一个脚本文件的内容?
【发布时间】:2016-10-24 20:44:40
【问题描述】:

如何打开一个应用脚本脚本文件,复制其内容,然后用复制的内容替换同一帐户中另一个应用脚本脚本文件的内容?

到目前为止我所拥有的:

// open file to copy from
var file = DriveApp.getFileById(fileIdToCopyFrom);

// copy file contents?
var copiedContents = file.getAs('text/plain'); // generates error: Converting from application/vnd.google-apps.script to application/pdf is not supported.  

// replace file contents with copied content
DriveApp.getFileById(fileIdToCopyTo).setContent(copiedContents);

【问题讨论】:

    标签: google-apps-script google-api google-drive-api google-apps


    【解决方案1】:

    看看Importing and Exporting Projects

    您在使用 Google Drive 的道路上是正确的,但您需要使用文档中描述的 API。

    关键是使用exportLinks 以 JSON 格式获取文件数据,此 ifo 可以推送到另一个应用程序脚本文件中。

    还要记住 MIME 类型是 application/vnd.google-apps.script

    【讨论】:

      猜你喜欢
      • 2016-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多