0

如何打開應用程序腳本腳本文件,複製其內容,然後用複製的內容替換同一帳戶中的其他應用程序腳本腳本文件的內容?如何複製一個腳本文件的內容並替換另一個腳本文件的內容?

我有什麼至今:

// 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); 

回答

0

看看Importing and Exporting Projects

您正在使用谷歌驅動器在正確的道路上,但你需要的文檔中描述使用API​​。

關鍵是將文件數據作爲JSON使用exportLinks這個ifo可以被推送到另一個應用程序腳本文件。請注意,MIME類型爲application/vnd.google-apps.script

相關問題