Google Apps 脚本:从 Google 表单提交创建 Google 共享云端硬盘文件夹

发布于 2025-01-14 20:13:14 字数 280 浏览 3 评论 0原文

I found this thread on creating a folder in Google Drive from a Google Form submission. Can any one help me on creating a folder but in Google Shared Drives instead from Google Form submission.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城花音 2025-01-21 20:13:14

如果您想通过修改以下脚本在共享驱动器中创建新文件夹,

function createFolder(form) {
  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.createFolder(name);
}

那么以下修改如何?目前阶段,幸运的是,使用了文件夹 ID,您可以通过 访问共享云端硬盘驱动服务

修改后的脚本:

function createFolder(form) {
  var folderId = "###"; // Please set the folder ID on the Shared Drive. If you want to create a new folder to the root folder of the Shared Drive, please set the Drive ID here.

  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.getFolderById(folderId).createFolder(name);
}
  • 在此修改中,folderId 是共享驱动器中特定文件夹的文件夹 ID 或共享驱动器的驱动器 ID。使用驱动器 ID 时,会在共享驱动器的根文件夹中创建文件夹。

注意:

  • 在这种情况下,您需要拥有写入共享驱动器的权限。请注意这一点。

参考:

If you want to create a new folder in the Shared Drive by modifying the following script,

function createFolder(form) {
  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.createFolder(name);
}

How about the following modification? In the current stage, fortunately, the folder ID is used, you can access the Shared Drive with Drive service.

Modified script:

function createFolder(form) {
  var folderId = "###"; // Please set the folder ID on the Shared Drive. If you want to create a new folder to the root folder of the Shared Drive, please set the Drive ID here.

  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.getFolderById(folderId).createFolder(name);
}
  • In this modification, folderId is the folder ID of the specific folder in the Shared Drive or the Drive ID of the Shared Drive. When the Drive ID is used, the folder is created to the root folder of the Shared Drive.

Note:

  • In this case, you are required to have permission for writing to the Shared Drive. Please be careful about this.

Reference:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文