0
votes

I am trying to bulk move folders from one Google Drive account to various user accounts. I have been playing around with Google Apps Script to see if I can do this. This is what is happening:

  1. Create Test Folder in my Drive
  2. From Google Apps Script, share the folder (edit rights) with another user
  3. Set the other user as the owner of the folder, this sets me with edit rights
  4. Remove myself from having any rights

At step 2 I am able to see the folder in the second users Drive (shared with me), but at step 3 the folder disappears from the second user all together. Any files that were in the folder can only be found in the 'Recent' section.

Has anyone seen this?

Here is the code function (I've shortened Ids and left out usernames)

function folderOps(){ 
  var folder = DriveApp.getFolderById('0ByoBlv24h2');
  folder.addEditor('username@domain.com');
  folder.setOwner('username@domain.com');
  folder.removeEditor('me@domain.com');     
}
1

1 Answers

0
votes

It's losing all parents information after transfering, just save the parents then set them again after setOwner:

function folderOps(){ 
  var folder = DriveApp.getFolderById('0ByoBlv24h2'),
      parents = folder.getParents();
  folder.addEditor('username@domain.com');
  folder.setOwner('username@domain.com');

  while( parents.hasNext() )
    parents.next().addFolder(folder);

  folder.removeEditor('me@domain.com');
}

Or maybe after removeEditor, I haven't been able to reproduce this.