Skip to content

Instantly share code, notes, and snippets.

@TomTasche

TomTasche/appsscript.js

Last active Feb 9, 2018
Embed
What would you like to do?
Remove access for user from multiple files on Google Drive - https://blog.tomtasche.at/2018/02/remove-user-from-multiple-documents.html
function main() {
findSharedDocuments("tomtasche@gmail.com");
}
function findSharedDocuments(email) {
var files = DriveApp.searchFiles('("' + email + '" in readers OR "' + email + '" in writers) AND NOT ("' + email + '" in owners)');
var success = 0;
while (files.hasNext()) {
var file = files.next();
try {
file.revokePermissions(email);
success++;
} catch (e) {}
Logger.log("file: " + file.getName());
Logger.log("success: " + success);
}
var files = DriveApp.searchFolders('("' + email + '" in readers OR "' + email + '" in writers) AND NOT ("' + email + '" in owners)');
var success = 0;
while (files.hasNext()) {
var file = files.next();
try {
file.revokePermissions(email);
success++;
} catch (e) {}
Logger.log("file: " + file.getName());
Logger.log("success: " + success);
}
}
function findOwnedDocuments(email) {
var files = DriveApp.searchFiles('"' + email + '" in owners');
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment