Changing ownership of files in Google Drive via Google Apps Script

This was a fun little exercise in Google Apps Script to essentially transfer ownership of Google Drive files from one user to another.

Here’s a script that the old user should run to change ownership of those files to the new user:

And here’s a script that the new user user should run to remove the old user as editor from the newly changed-ownership files:

Note: You cannot use the file.removeEditor() command to remove yourself as an editor, so that actually has to be run from the new owner’s account.

Another Note: Just as when you change ownership or add editorship manually, scripting will also produce a ton of emails to the new editor/owner that you’ve add that person, so the new editor/owner may want to set up some temporary Gmail filters to mark those as read and put into the trash.


  1. Hello Alan Siu,
    I assume this script works only for Google “native” files (as opposed to uploaded PDF, Office, jpg …), since there is this constraint in Google Drive. Is this correct ?
    Thanks and happy new year (could be better than 2020 😉

  2. I am trying to change ownership of a set of files in Drive for a set of users. Meaning I want each of my students to become owners of different files. Any ideas?

Leave a comment

Your email address will not be published. Required fields are marked *