Find Shared Drive containing a sub-folder by name

766 views
Skip to first unread message

James SEYMOUR

unread,
Apr 24, 2022, 9:38:44 PM4/24/22
to GAM for Google Workspace
Is it possible to find the name (or ID) of a Shared Drive using the name of a sub-folder inside the Shared Drive?

Thanks in advance.

James

Ross Scroggs

unread,
Apr 24, 2022, 10:40:25 PM4/24/22
to google-ap...@googlegroups.com
James,

gam user orga...@domain.com print filelist corpora onlyshareddrives query "name = 'Put Name Here'" fields id,name,driveid

driveId is the ID of the Shrared Drive.

Ross

Jerudong International School
https://www.jerudonginternationalschool.com
Follow us on:
http://www.facebook.com/jisbruneidarussalam http://www.twitter.com/jisbrunei http://www.instagram.com/jisbrunei https://www.youtube.com/user/JISBrunei https://www.flickr.com/photos/133960569@N03/albums

--
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/cab53eb7-d5ac-4a66-bddc-d136245e7051n%40googlegroups.com.

James SEYMOUR

unread,
Apr 25, 2022, 2:54:17 AM4/25/22
to google-ap...@googlegroups.com
Hi Ross,

Many thanks for the command. What I have now realised is that I need to convert the driveId that this command creates into the Shared Drive name. So I looked at plugging that command back into another. Both the variants of info & show work OK, but I am struggling with the print command (to eventually create a Google Sheet).

Info & Show work.
gam user <User Email Address> print filelist corpora onlyshareddrives query "name = '<Folder Name>'" fields id,name,driveid | gam csv - gam info teamdrive ~driveId
gam user <User Email Address> print filelist corpora onlyshareddrives query "name = '<Folder Name>'" fields id,name,driveid | gam csv - gam show teamdriveinfo ~driveId

Print is not working
I am not sure what the actual format the teamdriveadminquery needs to be in. I have tried different options, such as id:~driveId, id:~~driveId, "id = ~driveId" and the one below, but none work. This page https://developers.google.com/drive/api/guides/search-shareddrives does look like you cannot use ID in the query. Is that correct?
gam user <User Email Address> print filelist corpora onlyshareddrives query "name = '<Folder Name>'" fields id,name,driveid | gam csv - gam print teamdrives teamdriveadminquery "id = ~~driveId"

Am I missing something or is it not possible? 

Regards


James Seymour
Head of Systems and Communication
[t] +673.24.11.000  Ext 1203
[Time Zone] GMT +8 Hours


  I'm using Inbox When Ready to protect my focus.

James SEYMOUR

unread,
Apr 26, 2022, 1:37:33 AM4/26/22
to google-ap...@googlegroups.com
Thanks, Ross, for the call.

For anyone following this, the solution is to add showdrivename to the end of the command. This will show the Shared Drive Name.
gam user orga...@domain.com print filelist corpora onlyshareddrives query "name = '<Name of Folder>'" fields id,name,driveid showdrivename

Alternatively, if you add filepath then you get to see the full folder path.
gam user orga...@domain.com print filelist corpora onlyshareddrives query "name = 'Put Name Here'" fields id,name,driveid filepath

Add todrive to the end of the command to view the results in a Google Sheet.

Add excludetrashed, to prevent folders in the Bin being listed.

NB you may find that the number displayed in the output line is different to the final results. For example, the number 37 may be larger than the final results. This is because the number 37 refers to all the folders called <Name of Folder> (both in your My Drive and Shared Drives). GAMADV-XTD3 then filters out the folders from your My Drive.
Got 37 Drive Files/Folders that matched query ((name = '<Name of Folder>')) for <User Email Address>...

Regards


James Seymour
Head of Systems and Communication
[t] +673.24.11.000  Ext 1203
[Time Zone] GMT +8 Hours


  I'm using Inbox When Ready to protect my focus.
Reply all
Reply to author
Forward
0 new messages