how do you change the parent of a folder in a team drive. AddParents / RemoveParents generates an error "in a team drive a file has only one parent" and you can only read access to the parent collection. Should I make a copy of the file and delete the existing file?
Thank you
You need to remove the parent folder first then add the new parent.
Or you can do an update changing the parent from one to the next.
The main issue will be if this is even possible with team drive as your going to need to have the permission to do this.
Related
My understanding is that placing a file in multiple parent folders is no longer allowed on Drive (per the announcement of the single-parent model).
Using Google Apps Script methods (specifically DriveApp methods) to find the parent of a file, it seems I still have to obtain a folder iterator first using file.getParents(). Then use the folder iterator to find the parent folder.
Is this correct? I don't understand why there isn't a file.getParent() method now that would directly provide the parent folder.
Yes. That is correct. Currently, There isn't a file.getParent() method to directly get the parent Folder. You can create a feature request here.
When I am deleting a file from Google drive which someone else shared with me, it showed me a message like "one removed file is still accessible by collaborators".
It no longer appears in that folder, but will it be shown in "shared with me"? How can I delete it completely?
tl;dr
To completely delete file in gdrive of owner of the removed file:
Search for is:unorganized owner:me
Delete file
Remove it from trash (delete it permanently)
Explanation:
This is a common problem with Google Drive. Files removed from the Shared folder loses the location pointer and stays on the drive of the owner of the file with lost location property (cannot be accessible in standard way as we browse files in Google Drive).
The removed file can be found by searching for it by name or content, or using suggested the search phrase is:unorganized owner:me.
A scenario that commonly causes this problem and fix:
U (as you) and S(someone else) have shared folder with name Cats pictures
U add cat.jpg (and U is an owner of this file then)
S don't like this picture and use option Remove
The message removed file are still accessible by collaborators pops up
File cat.jpg is removed from shared folder Cats pictures
S is happy and never see a cat.jpg in Cats pictures folder
U cannot see this file either in Cats pictures folder but cat.jpg is still on U private Google Drive!
If U search in Google Drive for cat.jpg it find the file, and it location will be - (file lost it's location in folder tree).
The file found by U can be moved to Trash and then completely deleted 🎈
You mentioned you'd deleted the file from Google drive which was shared by someone else with you. After deleting you saw a message that stated, "one removed file is still accessible by collaborators". Perhaps the one who is sharing the file is one of the mentioned collaborators, or depending on how this document was shared, other members of the group.
Hope this helps!
Rename file a number then delete twice or 3 times it won't recognize it I had 6and there gone now
Google Drive has a cool feature: one can add a file or folder from Shared With Me to My Drive.
Then I can delete this file from My Drive in the same manner (note that if I delete shared file in web version it won't go to Trash)
However, I am getting 403 Forbidden error while trying to delete this file using Google Drive API (because of insufficient permissions due to that I am not owner of this file). So, as one can see, this is not a simple Delete request. How can I implement this functionality?
Add to My Drive changes the parents collection for the item in question. To change this, you will want to unparent the item rather than delete.
Use the about.get call to retrieve the My Drive ID, then remove that ID from the list of parents in the file resource for the file/folder. Update the file with the new list of parents.
A late answer, but I ran into this issue too. This happens because the file isn't actually copied, it's the same instance. If you remove it from My Drive, it will be removed from the Shared Drive too. And you may lack permission to remove it from the Shared Drive.
If you want to just remove it from My Drive: click on the file. In the right panel, under Details, there is a list of locations. At least the Shared Drive and My Drive is listed there. Click the X to remove it from My Drive, and it will disappear there while preserved on the Shared Drive.
This is what I found. After removing the parent of an item shared with me, do a sharedWithMe search still return the item, even though the item's parent list is empty.
Here is the code:
string sItemId = (this is the Id of the item shared with me);
string sParentId = driveService.About.Get().Execute().RootFolderId;
driveService.Parents.Delete(sItemId, sParentId).Execute();
var parentList = m_driveService.Parents.List(sItemId).Execute();
At this point parentList.Items.Count is 0.
Now when I search sharedWithMe the item is in the return list.
I'm playing with the Google Drive API and one thing that I keep wondering about is IDs in the case of an arbitrary file (non-Google App) like an image.
If a user is working locally, offline and they turn off the Google Drive client. And then they make some changes to a file, let's say they rename it, move it from one folder to the next and edit it.
Will the ID remain the same when the client comes back on, or will it break? I imagine the client will interpret either one or all of the move, rename and edit as delete and new file.
Would appreciate any help here!
The file id (within Google Drive) remains the same from the original creation to its deletion.
I have a document (FILE-1) with two parent folders (FOLDER-1 and FOLDER-2).
If I delete FOLDER-1, FILE-1 is also deleted. However, I expected that only FOLDER-1 would be deleted, and removed as a parent of FILE-1, which would be left intact.
Is this the intended behavior, or a bug?
It appears to be by design according to this Google Drive support documentation. It seems as though trashing a folder and removing a parent from a file are two completely different things.
3. The folder will be moved to Trash, and all items in that folder will also be moved to Trash.
I also found same thing but I think they want this only..that when a folder is moved to trash all the items in that folder will also be moved to trash.
They might have done something like if you are willing to delete a folder they would have asked for the confirmation messaging whether user wants to delete files inside it or not and if not they would have asked user to move it to another folder but again its there choice and there way of thinking.