Remove MyDrive shortcut from Google Drive files

1,321 views
Skip to first unread message

Jon Pankhurst Suitebriar

unread,
Feb 11, 2021, 5:47:55 PM2/11/21
to GAM for Google Workspace
Hi,

Is there a way to remove files from the My Drive Shortcut from Drive files in bulk??

Please let me know when you have the chance.


Thank you,
Jon

Jay Lee

unread,
Feb 11, 2021, 5:50:07 PM2/11/21
to google-ap...@googlegroups.com
You want to remove the shortcut to a file/folder that's in the root of a user's My Drive? Can you screenshot what you mean exactly?

Hope you're well btw Mr. Pankhurst.

Jay Lee


--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/82f15928-e21c-4dae-b9ac-0acaf71c69b8n%40googlegroups.com.

Jon Pankhurst

unread,
Feb 11, 2021, 6:00:26 PM2/11/21
to google-ap...@googlegroups.com
Hi Jay,

I have a person who has all of the contents of one of his folders in his My Drive and would like ot remove all of the MyDrive Links removed from the files.  Do you think there is any chance on this one?


Thank you,

Jon Pankhurst

Sales Engineer - Suitebriar

A Google Cloud Premier Partner

#stayhomestaysafe

j...@suitebriar.com

(815) 862-3406

www.suitebriar.com



You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/KJzePbqNpZg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/CA%2BVVBp-SB9SZKwU%3Dt%3Dd_mGJ8DVa9CaCn_Wq6oEjsx4ymF052mw%40mail.gmail.com.

Jay Lee

unread,
Feb 11, 2021, 6:09:25 PM2/11/21
to google-ap...@googlegroups.com
"would like ot remove all of the MyDrive Links removed from the files"

I read that 3 times and still could not parse it and the screenshot didn't give me each other. Can you offer full detail of what the user is seeing and wants removed?

Jay Lee


Jon Pankhurst

unread,
Feb 12, 2021, 5:03:37 PM2/12/21
to google-ap...@googlegroups.com
Hi Jay,

Lets see if this makes more sense.  

Hey Jon,

Best I can describe it is that all the contents in our shared company folder has been added to "My Drive" as a shortcut. No files/folders have been moved or duplicated, but aliases of every file/folder have been added to "My Drive". How can I remove these shortcuts/aliases from My Drive without moving the source files?

Screenshot attached of what "My Drive" looks like when I go to the homepage of Google Drive. Note in the Details panel the file locations. 

image.png

Let me know if you think there is anything that can be done.

Thank you,

Jon Pankhurst

Sales Engineer - Suitebriar

A Google Cloud Premier Partner

#stayhomestaysafe

j...@suitebriar.com

(815) 862-3406

www.suitebriar.com


Brian Kim

unread,
Feb 12, 2021, 5:41:01 PM2/12/21
to GAM for Google Workspace
Hey Jon,

Something along the lines of 

gam redirect csv. ./files.csv user jon print filelist showmimetype gshortcut fields id

then

gam csv files.csv user jon delete drivefile ~id

In case you have shortcuts in your My Drive that you may want to keep, you might want to play with the output of the CSV file so you can review the content before executing the delete command.

Ross Scroggs

unread,
Feb 12, 2021, 8:07:47 PM2/12/21
to google-ap...@googlegroups.com
Jon,

Brian's version will delete all of a user's shortcuts, this example only deletes the shortcuts directly in My Drive.

# Get ID of My Drive                                                                                                                                                                                                             

$ gam user us...@domain.com show fileinfo root fields id

User: us...@domain.com, Show 1 Drive File/Folder

  Drive Folder: My Drive (012YenC8f12ALUk9XYZ)

    id: 012YenC8f12ALUk9XYZ


# Find all shortcuts directly in My Drive                                                                                                                                                                                        

$ gam redirect csv ./shortcuts.csv user us...@domain.com print filelist query "(mimeType = 'application/vnd.google-apps.shortcut') and ('012YenC8f12ALUk9XYZ' in parents)" fields id,name,mimetype

Getting all Drive Files/Folders that match query ('me' in owners and ((mimeType = 'application/vnd.google-apps.shortcut') and ('012YenC8f12ALUk9XYZ' in parents))) for us...@domain.com

Got 1 Drive File/Folder that matched query ('me' in owners and ((mimeType = 'application/vnd.google-apps.shortcut') and ('012YenC8f12ALUk9XYZ' in parents))) for us...@domain.com...


# Verify that shortcuts.csv makes sense                                                                                                                                                                                          

$ more shortcuts.csv

Owner,id,name,mimeType

us...@domain.com,012bpr8ilJYF-ELVTg1P8xbUzcOfs4xyz,My Doc,application/vnd.google-apps.shortcut


# Delete shortcuts                                                                                                                                                                                                               

$ gam user us...@domain.com delete drivefile csvfile shortcuts.csv:id

User: us...@domain.com, Trash 1 Drive File/Folder

  User: us...@domain.com, Drive File/Folder: My Doc 1, Trashed


Ross



--

Ross Scroggs

unread,
Feb 13, 2021, 10:38:19 AM2/13/21
to google-ap...@googlegroups.com
Jon,

I think that Jay and Brian and I were all mislead by your use of the term My Drive shortcut.
My Drive is not a shortcut, it the user's root folder.

It doesn't appear to me now that this involves shortcuts at all, but unwanted folders located in My Drive.
Is that correct?
In your latest screenshot, the highlighted folder is owned by the user and is shared to others.
If the folder is deleted, others lose access to it.
Where did these folders come from?

Brian Kim

unread,
Feb 13, 2021, 11:09:43 AM2/13/21
to GAM for Google Workspace
Hey Ross,

I assume they were created by Cloud M Migrate. When I asked them previously about the ability to multi-parent files (due to Sept 30th change) they indicated they somehow had an exemption to the change in API behaviour.

It looks like the file is on both the user's My Drive, as well as another folder called !Edits. But the owner is the user that is in Jon's screenshot.

Google-to-Google migrations are now even messier because of this.

Brian Kim

unread,
Feb 13, 2021, 11:13:15 AM2/13/21
to GAM for Google Workspace
For Jon - I would suggest creating a ticket with CloudM and showing a side by side picture of user's My Drive (both source and destination). I don't think they quite understood the implication of the change in API behaviour. Sure it can be fixed using GAM eventually, but for a paid product, they should be doing a better job of handling things like these.

Jon Pankhurst

unread,
Feb 13, 2021, 11:15:47 AM2/13/21
to google-ap...@googlegroups.com, JB Rowland
This was correct, I was going off of the fact that the client would remove the MyDrive from the right side options of the folder.  I think that you have the correct context.

Thank you,

Jon Pankhurst

Sales Engineer - Suitebriar

A Google Cloud Premier Partner

#stayhomestaysafe

j...@suitebriar.com

(815) 862-3406

www.suitebriar.com


Brian Kim

unread,
Feb 14, 2021, 8:38:33 AM2/14/21
to GAM for Google Workspace
Hey Ross,

Wouldn't it be possible to delete one of the parents?

I believe this behaviour is because it's no longer able to orphan a file (i.e. if you intentionally try to orphan a file, it will put the file back in user's My Drive). 

removeparents <id for user's root> might work.. but being able to identify multi-parented files might be hard. CloudM might have this in the SQL database.

Maybe checking for inherited permissions for each file using GAM?

Jon Pankhurst

unread,
Feb 16, 2021, 12:53:35 PM2/16/21
to google-ap...@googlegroups.com, JB Rowland
Yes, I confirm what Ross said, we want to eliminate the My Drive, to reduce clutter in the Google Drive.

Thank you,

Jon Pankhurst

Sales Engineer - Suitebriar

A Google Cloud Premier Partner

#stayhomestaysafe

j...@suitebriar.com

(815) 862-3406

www.suitebriar.com


Message has been deleted
Message has been deleted

Brian Kim

unread,
Feb 16, 2021, 2:41:20 PM2/16/21
to GAM for Google Workspace
Third time is the charm.. my message keeps getting deleted when posting with my work account.

gam user <username> show fileinfo <fileId>

This shows parents.

Screenshot 2021-02-16 141550.png

gam user <username> print filelist showparent

This shows number of parents as well as parents.[i].id
Screenshot 2021-02-16 142305.png

gam user <username> print filelist showparentidsaslist

This shows parentIds in one cell.
Screenshot 2021-02-16 142328.png

With this finding, you can probably do 
gam config csv_output_row_filter "'parents:count>1'" user <username> print filelist showmimetype gfolder depth 0 anyowner fields id,title,parents depth 0

anyowner is necessary if the folders in question are owned by "me" or someone else (which seems to be the case for you)

Jon Pankhurst

unread,
Feb 18, 2021, 9:20:27 AM2/18/21
to google-ap...@googlegroups.com
We had a session with Ross and got it figured out!

Thank you again Ross!

Jon Pankhurst

Sales Engineer - Suitebriar

A Google Cloud Premier Partner

#stayhomestaysafe

j...@suitebriar.com

(815) 862-3406

www.suitebriar.com



On Thu, Feb 18, 2021 at 5:50 AM Brian Kim <bria...@strataprime.com> wrote:
Maybe Ross can bring this one home,

When I do gam user <username> show fileinfo <fileID>

I can see that the file has two parents.

Screenshot 2021-02-16 141550.png

However, if I do gam print filelist, you can show parents by including showparents
Screenshot 2021-02-16 142305.png

Or
showparentsidsaslist, which will merge the parent IDs into one cell.

Screenshot 2021-02-16 142328.png

You can do something like gam config csv_output_row_filter "'parents:count>1'" with your filelist to identify the files with multiple parents, or use regex/notregex.. though thinking about regex hurts my head when querying multiple fields (parent.*id)
Reply all
Reply to author
Forward
0 new messages