Friday, February 9, 2018

Remove access for user from multiple files on Google Drive

Sometimes people leave a project and you want to make sure they don't have access to any of your potentially confidential documents, or make further changes to important data you collected in spreadsheets. A friend of mine recently faced such an issue and I tried to solve his pain. At first I came across an article to remove access to multiple documents via the Google Drive website. This worked, but turns into a tedious task if you have lots of files!

I turned to Google Apps Script for a solution because I had a nice experience with it in the past. I was able to build a script within a very short time that does exactly what I need, but has some drawbacks:
  • does not work for files which are owned (created) by the user you want to remove
  • you need to manually run the script a lot of times, because there is a limit for how long a script can run continuously. Since Apps Script operates quite slow, you easily reach that limit. However, the script goes on where it stopped the next time you run it!

To use this create a new project at, copy the script into it, enter the email of the user you want to remove and run it. At some point it will tell you that the script failed, but you can run it again at this point. You will have to repeat that a lot of times, so be patient...

One could further improve this with a simple UI and triggers to re-run the script automatically before it reaches the time limit, but it did the trick for me so I thought I'd share it here!

No comments:

Post a Comment