Last active
February 10, 2022 09:51
-
-
Save TomTasche/4390e5732e4627fe8801a75cc8f91332 to your computer and use it in GitHub Desktop.
Remove access for user from multiple files on Google Drive - https://blog.tomtasche.at/2018/02/remove-user-from-multiple-documents.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
findSharedDocuments("[email protected]"); | |
} | |
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