Google云端硬盘有一个问题:如果您取消共享顶级文件夹,该文件夹中的所有内容仍然是共享的......我不确定这么大的错误是如何存活的,但它确实...详情请点击此处:
http://productforums.google.com/forum/#!topic/drive/p3LZQnRNB24
我不想手动浏览并取消手动删除所有内容,所以我想我可以创建一个脚本,我可以将文件夹ID插入其中并让它完成所有工作。
我该怎么做?
答案 0 :(得分:3)
这会使驱动器中每个文件夹和文件中的某个人无关。
// 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 + ")"); }
}
答案 1 :(得分:0)
上面发布的代码示例只是在添加电子邮件地址后复制粘贴并运行时发出错误。
http://i.imgur.com/fbJr6eG.png
//创建Google文档//工具/脚本编辑器//粘贴它 //更新第13行并保存//点击播放以运行。你可能要跑 几次,因为剧本将在5或6分钟后死亡。
function findSharedFolders(){// https://developers.google.com/apps-script/reference/drive/drive-app
// https://developers.google.com/drive/web/search-parameters // How do I script Google Drive to unshare all subfolders and files given a folder ID? // https://productforums.google.com/forum/#!topic/drive/p3LZQnRNB24var email =“unwanted-address@gmail.com”; //&lt;&lt;&lt;&lt;&lt;&lt;插入 这里没有发送电子邮件地址
var body = DocumentApp.getActiveDocument()。getBody();
body.appendParagraph(电子邮件).setHeading(DocumentApp.ParagraphHeading.HEADING1); var folders = DriveApp.searchFolders(作家中的“'”+ email +“');而 (folders.hasNext())unshare_(folders.next(),body,email); var文件 = DriveApp.searchFiles(作家中的“'”+电子邮件+“); while(files.hasNext())unshare_(files.next(),body,email); }function unshare_(file,body,email){// Logger.log(file.getName()); var para = body.appendParagraph(file.getName());尝试{ file.removeEditor(电子邮件); } catch(e){ para.setLinkUrl(file.getUrl()); para.appendText(“(”+ e +“)”); }}
答案 2 :(得分:0)
上述答案效果很好,但应该在谷歌文档中运行(用于记录信息)。
如果您想直接在脚本编辑器中使用它,只需使用上面的代码而不使用日志:
// 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 folders = DriveApp.searchFolders("'"+email+"' in writers"); while (folders.hasNext()) unshare_(folders.next(), email);
var files = DriveApp.searchFiles( "'"+email+"' in writers"); while ( files.hasNext()) unshare_( files.next(), email);
}
function unshare_(file, email) {
// Logger.log(file.getName());
try { file.removeEditor(email); }
catch (e) { }
}
答案 3 :(得分:0)
我发现此脚本https://github.com/HR/google-drive-unshare可以与某人完全取消共享文件和文件夹或特定文件夹(及其ID)并转让其所有权(在取消共享的同时复制其拥有的所有文件和文件夹)