我有多个父母的文件。我想要额外的东西,只保留我喜欢的。如何实现这一目标。类似于下面代码中说明的语句
var parentCount=0;
var driveFile = DriveApp.getFileById(id);
var parentFolder = driveFile.getParents();
while (parentFolder.hasNext()) {
var folder = parentFolder.next();
parentCount++;
if(folder.getName()=="I don't want this")
driveFile.removeParentLocation(folder) //Not a legal Method. needs workaround
}
答案 0 :(得分:1)
在上面的评论中回答
var parentCount=0;
var driveFile = DriveApp.getFileById(id);
var parentFolder = driveFile.getParents();
while (parentFolder.hasNext()) {
var folder = parentFolder.next();
parentCount++;
if(folder.getName()=="I don't want this")
driveFile.removeParentLocation(folder)
}
编辑评论:请注意@tanaike folder.removeFile(driveFile)上面的第一条评论