1

I am trying to move a file from one folder in a Google shared (team) drive to another folder in the same drive. I have used the following code in non-shared drive successfully, but when I try to use it in a shared drive, I get an error

Exception: Cannot use this operation on a share drive item. (line x, file "Code")

function moveFile(fileID, folderID) {
  var file = DriveApp.getFileById(fileID).makeCopy();
  DriveApp.getFolderById(folderID).addFile(file); 
}

I can't find any documentation on why shared drives behave differently. I would love either education on why shared drives are different and/or alternative code which achieves my needs.

(I know this code misses details like renaming the file and removing the copy from the original directory... those are easy to solve, so I don't want to complicate this question.)

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • From June 1, 2020, Drive service got to be able to use the shared Drive. But in the current stage, it seems that all methods might not be able to be used. But in your case, your goal can be achieved using the Drive service. When own Google Drive is used for `folderID` in your script, the copied file has 2 parents. But when the shared Drive is used for `folderID`, I could confirm that the copied file can be put to the shared Drive. So for example, how about confirming the permissions for the shared Drive again? – Tanaike Jun 28 '20 at 22:42

0 Answers0