How to list all Files and folders within a specific Shared Drive?

2,164 views
Skip to first unread message

Hardy Patel

unread,
Feb 17, 2021, 5:08:37 PM2/17/21
to GAM for Google Workspace
Hi All, 

I hope someone can help with this.I am using GAM advance  and used the following command to get a list of all shared drives within the domain.

 " gam print teamdriveacls oneitemperrow todrive"

I know need to get a full list of files and folders within each of these shared drives i have identified.

I still don't know how to do this. Assuming i will need to do a print command using the Drive ID or Name. Any help is appreciated. 

Thanks, 
Hardy 

Ross Scroggs

unread,
Feb 17, 2021, 5:35:10 PM2/17/21
to google-ap...@googlegroups.com
Hardy,

Here's a start:

# 1: Get list of Team Drives                                                                                                                                                                                                                             

#  $ gam redirect csv ./TeamDrives.csv print teamdrives fields id,name                                                                                                                                                                                   

# 2: Get ACLs for all Team Drives                                                                                                                                                                                                                        

#  $ gam redirect csv ./TeamDriveACLs.csv multiprocess csv TeamDrives.csv gam print drivefileacls ~id fields emailaddress,role,type                                                                                                                      

# 3: From that list of ACLs, output a CSV file with headers "id,name,organizers" that shows the organizers for each Team Drive                                                                                                                           

# 4: Customize GetTeamDriveOrganizers.py                                                                                                                                                                                                                 

#    Set DOMAIN_LIST as desired                                                                                                                                                                                                                          

#    Set ONE_ORGANIZER = True                                                                                                                                                                                                                            

#    Set SHOW_GROUP_ORGANIZERS = False                                                                                                                                                                                                                   

#    Set SHOW_USER_ORGANIZERS = True                                                                                                                                                                                                                     

#  $ python3 GetTeamDriveOrganizers.py TeamDriveACLs.csv TeamDrives.csv TeamDriveOrganizers.csv                                                                                                                                                          

# 5: Get Team Drive files                                                                                                                                                                                                                                

#  $ gam redirect csv ./TeamDriveFiles.csv multiprocess csv TeamDriveOrganizers.csv matchfield organizers "^.+$" gam user ~organizers print filelist select teamdriveid ~id fields <ListOfDesiredFields>  


Ross                                               


The information contained in this email is privileged and confidential and intended for the addressee only. If you are not the intended recipient, please respect that confidentiality and do not disclose, copy or make use of its contents. If received in error, please destroy this email and contact the sender immediately. Thank you.

--
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/13d71978-f65b-48f5-8d1b-6d820ac201b9n%40googlegroups.com.


--

Hardy Patel

unread,
Feb 18, 2021, 5:23:29 PM2/18/21
to google-ap...@googlegroups.com
Hi Ross, 

Thanks for providing this information, i will give it try. 

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/ydLlYDlabnE/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/CAJkvRS-5%3D62Ww_yLUbNy0keT7Cx_wJyn73TW_h7Le0dPOo0Uig%40mail.gmail.com.


--

Hardy Patel
Technical Consultant
Fronde

 

Fronde Logo

Sydney, Australia
m.   | e. hardy...@fronde.com | w. www.fronde.com

Rob Chalmers

unread,
Dec 13, 2024, 6:52:36 AM12/13/24
to GAM for Google Workspace
Hi Ross

I found this old thread that describes exactly what I need to do ie show all file and folders (with paths) for all Shared Drives

I can't get the last command to work (sorry I'm a noob at GAM / scripting) : gam redirect csv ./TeamDriveFiles.csv multiprocess csv TeamDriveOrganizers.csv matchfield organizers "^.+$" gam user ~organizers print filelist select teamdriveid ~id fields modifiedtime filepath todrive

zsh: no such user or named directory: organizers


I can get results from individual Shared Drives with: 


"gam user user...@domain.uk print filelist select teamdrive <GDriveName> showownedby any id title filepath"


What am I doing wrong?


Thanks

Rob




Ross Scroggs

unread,
Dec 13, 2024, 10:04:38 AM12/13/24
to google-ap...@googlegroups.com
You need quotes and you probably want more fields;

Do you want a local file (TeamDriveFiles.csv), a Google Sheet (todrive) or both

# Local file
gam redirect csv ./TeamDriveFiles.csv multiprocess csv TeamDriveOrganizers.csv matchfield organizers "^.+$" gam user "~organizers" print filelist select teamdriveid "~id" fields id,name,driveid,mimetype,modifiedtime showdrivename filepath

# Google Sheet
gam redirect csv - multiprocess todrive csv TeamDriveOrganizers.csv matchfield organizers "^.+$" gam user "~organizers" print filelist select teamdriveid "~id" fields id,name,driveid,mimetype,modifiedtime showdrivename filepath

# Both
gam redirect csv./TeamDriveFiles.csv  multiprocess todrive tdlocalcopy csv TeamDriveOrganizers.csv matchfield organizers "^.+$" gam user "~organizers" print filelist select teamdriveid "~id" fields id,name,driveid,mimetype,modifiedtime showdrivename filepath

Ross

----
Ross Scroggs



Rob Chalmers

unread,
Dec 13, 2024, 12:47:03 PM12/13/24
to GAM for Google Workspace
Hi Ross

that's perfect - exactly what I needed

Help much appreciated
Rob

Reply all
Reply to author
Forward
0 new messages