title: Is there a way to set owner of Google Folder / Files through script?
body: <p>I am the Owner of a File / Folder and want to set the owner of the File and Folder through script to somebody else. It is part of a bigger code where I go through all subfolders and files of a given folder and want to give the ownership to somebody else. Problem is that the command 'setOwner()' does not work.</p>
  
  <p>I have tried with the command folder.setOwner(Email Address) and it gave me the error message 'Invalid argument (line x, file "Code")' Dismiss
  '. Also I tried with the command folder.setOwner(User), got the same error message again. </p>
  
  <pre><code> var rootfolder = DriveApp.getFolderById(folderId);
   rootfolder.setOwner("email@domain.com");  //line x
  </code></pre>
  
  <p>or</p>
  
  <pre><code> var newOwner = DriveApp.getFileById(FileId).getOwner();
   var rootfolder = DriveApp.getFolderById(folderId);
   rootfolder.setOwner(newOwner); //line x
  </code></pre>
  
  <p>Note: 'FileId' is from a Public File</p>
  
  <p>I also tried this Code, which worked. I got Email from Google Drive that the given folder was transfered from me to me.</p>
  
  <pre><code> var rootfolder = DriveApp.getFolderById(folderId);
   rootfolder.setOwner(rootfolder.getOwner());
  </code></pre>
  
  <p>But I do not want to transfer it to myself, but to somebody else.</p>
  
  <p><s>(I tried it on my personal and on my GSuite Account to a personal &amp; GSuite account &amp; all possibilities in between, nothing works)</s></p>