0

The reference about File.getParents() and File.makeCopy is unclear.

For File.getParents, what will be returned(are they all ancestor folders along with the path or are they all parent folders because File is possible to have multiple parent folders?), and in what order?

For File.makeCopy, which folder will the new file be located if File has multiple parents?

From some testing, it seems getParents always put Root folder as the last element in returned array if root folder is one of the parents no matter when it is added to parent list, other folders are randomly ordered. makeCopy always put the new file into Root folder even the original file has no Root as its parent.

EDIT: Someone said "The DriveApp Service was updated August 20, 2013, with new methods File.makeCopy(destination) and File.makeCopy(name, destination), which allow scripts to specify a folder to which a file should be copied." in this post. but i just tested it does not work as of today.

Also there is a delay for removeFromFolder() to take effect. Sometime you can see file located both at root folder and its designated foler.

Please explain.

Community
  • 1
  • 1
Michael SM
  • 715
  • 3
  • 11
  • 25

1 Answers1

0

Your observations are correct , Root is always the top parent of any file (that's why it called "root") unless you remove it explicitely (see this post for example) and when you copy (or create) a file, this file is always in Root, no matter where it comes from and it's up to you to move it at the right place (many posts around here on that subject) EXCEPT when you make a copy using folder.createFile() and similar... in that case the file is only present it its parent folder.

Community
  • 1
  • 1
Serge insas
  • 45,904
  • 7
  • 105
  • 131