小编pum*_*mer的帖子

如何在 Google Apps Script 中获取“这个”文件的当前实例?

我正在尝试创建对当前 DriveApp 文件对象(即脚本本身的实际 Google Drive 容器)的引用。这是我想要做的:

// Assume that thisFile is a FileIterator pointing to THIS file.
// My question in a nutshell: How do I get thisFile?
DriveApp.getFileById( thisFile.getId() );
Run Code Online (Sandbox Code Playgroud)

我想这样做而不是 DriveApp.getFileById(id) 因为我不想“硬编码”脚本文件的 ID 字符串。这样,如果我制作 Google Apps Script 项目的副本,则不必在 Code.gs 或 Script Properties 中编辑任何内容。有什么建议?

javascript google-apps-script google-drive-api

4
推荐指数
2
解决办法
1980
查看次数