本文介绍了如何编写 Google Drive 脚本以取消共享给定文件夹 ID 的所有子文件夹和文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Google 云端硬盘有一个问题:如果您取消共享顶级文件夹,该文件夹中的所有内容仍然是共享的...我不确定如此大的错误如何能够幸存下来,但它确实存在...详细信息在这里:
Google Drive has a problem: if you unshare a top level folder everything in the folder is still shared...I'm not sure how such a large bug could survive but it does...details here:
http://productforums.google.com/forum/#!topic/驱动器/p3LZQnRNB24
我不想手动完成并手动取消共享所有内容,所以我想我可以创建一个脚本,我可以将文件夹 ID 插入并让它完成所有工作.
I don't want to manually go through and unshare everything manually, so I'm thinking I could create a script that I could just plug in the folder ID into and have it do all the work.
我该怎么做?
推荐答案
这会取消共享驱动器中每个文件夹和文件中的某个人.
this unshares someone from every folder and file in your drive.
// 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 = "[email protected]"; // <<<<< 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 Drive 脚本以取消共享给定文件夹 ID 的所有子文件夹和文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!