Transfer ownership of a file to another user in Google Apps Script

Unfortunately changing the owner of a file isn’t supported in Apps Script. Issue 74 is a feature request to add this ability, and if you star the issue you’ll show your support for the feature and get notified of updates.

——EDITED——

Now there is a handy method called setOwner, which can be found here: https://developers.google.com/apps-script/reference/drive/file#setOwner(User)

There’s also the possibility to pass the new owner’s email address instead of the User object, which is even more handy in some cases:
https://developers.google.com/apps-script/reference/drive/file#setOwner(String)

Leave a Comment