gpt4 book ai didi

google-apps-script - 如何编写 Google Drive 脚本以取消共享给定文件夹 ID 的所有子文件夹和文件?

转载 作者:行者123 更新时间:2023-12-01 02:19:59 24 4
gpt4 key购买 nike

Google 云端硬盘有一个问题:如果您取消共享顶级文件夹,该文件夹中的所有内容仍会共享...我不确定这么大的错误如何幸存,但它确实存在...详细信息:

http://productforums.google.com/forum/#!topic/drive/p3LZQnRNB24

我不想手动浏览和取消共享所有内容,所以我想我可以创建一个脚本,我可以将文件夹 ID 插入其中并让它完成所有工作。

我该怎么做呢?

最佳答案

这会从驱动器中的每个文件夹和文件中取消共享某人。

// create a Google Document
// Tools / Script Editor
// paste this in
// update line 13 and save
// hit play to run. you may have to run several times as the script will die after 5 or 6 minutes.

function findSharedFolders() {
// https://developers.google.com/apps-script/reference/drive/drive-app
// https://developers.google.com/drive/web/search-parameters
// http://stackoverflow.com/questions/21227771/how-do-i-script-google-drive-to-unshare-all-subfolders-and-files-given-a-folder
// https://productforums.google.com/forum/#!topic/drive/p3LZQnRNB24

var email = "unwanted-address@gmail.com"; // <<<<< INSERT THE UNDESIRED EMAIL ADDRESS HERE

var body = DocumentApp.getActiveDocument().getBody();
body.appendParagraph(email).setHeading(DocumentApp.ParagraphHeading.HEADING1);
var folders = DriveApp.searchFolders("'"+email+"' in writers"); while (folders.hasNext()) unshare_(folders.next(), body, email);
var files = DriveApp.searchFiles( "'"+email+"' in writers"); while ( files.hasNext()) unshare_( files.next(), body, email);
}

function unshare_(file, body, email) {
// Logger.log(file.getName());
var para = body.appendParagraph(file.getName());
try { file.removeEditor(email); }
catch (e) { para.setLinkUrl(file.getUrl()); para.appendText(" (" + e + ")"); }
}

关于google-apps-script - 如何编写 Google Drive 脚本以取消共享给定文件夹 ID 的所有子文件夹和文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21227771/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com