如何将Google云端硬盘脚本编制为取消共享给定文件夹ID的所有子文件夹和文件? [英] How do I script Google Drive to unshare all subfolders and files given a folder ID?

查看:107
本文介绍了如何将Google云端硬盘脚本编制为取消共享给定文件夹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 / drive / 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.

我该怎么做?

推荐答案

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

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 = "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云端硬盘脚本编制为取消共享给定文件夹ID的所有子文件夹和文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆