Team Drive list of files in a folder and all its subfolders...for all users

4,310 views
Skip to first unread message

Constantly Learning

unread,
Jun 27, 2018, 5:58:07 PM6/27/18
to GAM for G Suite
Hi Ross and others,

Tried to figure this out on my own but could not.

I have a team drive called "ABC" and it has several subfolders, one of which is called "DEF".

"DEF" in turn has multiple subfolders, each with many files, as well as possibly some plain old files in the DEF root. There are many different owners -- user1, ...user18.

So how do I get a directory listing of everything in DEF, for every user owner? 

I tried this via GAM-ADVX

gam user us...@mydomain.com print filelist select anydrivefilename "ABC" showownedby any id title filepath > file.csv

and, that gives me everything owned by us...@mydomain.com, with the path for all the files in the ABC team drive. Brilliant, but only for user1.

Is there an Advanced GAM command to do the above but for every user in the team drive? Or do I need a Python script?

Help would be greatly appreciated! Thanks in advance.

Ken

Constantly Learning

unread,
Jun 27, 2018, 6:23:10 PM6/27/18
to GAM for G Suite
Hmm...actually I realize that the command I mention below only found some ABC folder files that were not in Team Drive so I'm thinking that this doesn't work for Team Drive, right?

gam user us...@mydomain.com print filelist select anydrivefilename "ABC" showownedby any id title filepath > file.csv

Back to square one. Any ideas? How to get this to work for a Team drive folder and how to get it to return results for all user-owners who have files in the Team Drive folder?

Help would be greatly appreciated. Thanks.

Ken

Constantly Learning

unread,
Jun 27, 2018, 6:37:47 PM6/27/18
to GAM for G Suite
Hmm...found this command in GAMADV-XTD

gam <UserTypeEntity> show filetree [anyowner|(showownedby any|me|others)]
        [select <DriveFileEntity>|orphans] [depth <Number>] (orderby <DriveOrderByFieldName> [ascending|descending])*

But how to get it to work for what I'm trying to do? Help!

Ken

Ross Scroggs

unread,
Jun 27, 2018, 6:43:43 PM6/27/18
to google-ap...@googlegroups.com
Ken,

gam user us...@domain.com print filelist select teamdrive "ABC" teamdrivefilename "DEF" showownedby any id title filepath > file.csv


Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/61686763-6166-4726-b88b-8df54ec7471f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Constantly Learning

unread,
Jun 28, 2018, 10:40:47 AM6/28/18
to GAM for G Suite
This worked like a charm. Thank you so much, Ross!

Ken

+KimNilsson

unread,
Jul 6, 2018, 12:05:07 PM7/6/18
to GAM for G Suite
@Ross,

With userATdomain.com being any user with access to the TD, or must it be someone with a specific user level?

Ross Scroggs

unread,
Jul 6, 2018, 12:35:58 PM7/6/18
to google-ap...@googlegroups.com
Kim,

It depends on what fields you want, for instance, readers can't see permissions but can see other fields.

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.


--

Oleg Brendel

unread,
Mar 13, 2019, 11:16:15 AM3/13/19
to GAM for G Suite
this is awesome!


On Thursday, 28 June 2018 00:43:43 UTC+2, Ross Scroggs wrote:
Ken,

gam user us...@domain.com print filelist select teamdrive "ABC" teamdrivefilename "DEF" showownedby any id title filepath > file.csv


Ross


On Wed, Jun 27, 2018 at 3:37 PM Constantly Learning <k...@walkersands.com> wrote:
Hmm...found this command in GAMADV-XTD

gam <UserTypeEntity> show filetree [anyowner|(showownedby any|me|others)]
        [select <DriveFileEntity>|orphans] [depth <Number>] (orderby <DriveOrderByFieldName> [ascending|descending])*

But how to get it to work for what I'm trying to do? Help!

Ken

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--

Temple Rodgers

unread,
Sep 22, 2021, 10:18:31 AM9/22/21
to GAM for Google Workspace
hm, has something happened with this? I'm getting an error and I can't fathom what's wrong ... gam user user...@domain.uk print filelist select teamdrive <driveid> teamdrivefilename <Gfolderid> showownedby any id title filepath
gives me the error "Print Failed: Does not exist"

I've checked, checked, checked the driveID and the teamdrive folder id too and they are correct. I even took away the folder and just left the drive, but that didn't work. I tried with and without quotes but that didn't work.

I'm guessing something simple

Ross Scroggs

unread,
Sep 22, 2021, 10:32:21 AM9/22/21
to google-ap...@googlegroups.com
Temple,

If you have a folder ID (as opposed to a folder name) you can just specify that folderID
gam user user...@domain.uk print filelist select teamdriveid <Gfolderid> showownedby any id title filepath

If you have a folder name, then you specify the team drive id and the folder name.
gam user user...@domain.uk print filelist select teamdriveid <driveid> teamdrivefilename <Gfolderid> showownedby any id title filepath

Ross

Disclaimers apply, for full details see: https://hackney.gov.uk/email-disclaimer


--
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/0a61e19f-2ac8-4061-b870-51a506328b23n%40googlegroups.com.


--

Temple Rodgers

unread,
Sep 22, 2021, 10:51:16 AM9/22/21
to GAM for Google Workspace
thank you @Ross - if I use the actual ID of the folder then it doesn't work (your first suggestion) and gives the error message "Shared drive not found" ... I guess because it's a folder and not a shared drive .. 

if I use the teamdriveid <id> and the teamdrivefilename "02 second batch" it works thank you! I can use that for now, but I hate being beaten by syntax!

Ross Scroggs

unread,
Sep 22, 2021, 11:00:45 AM9/22/21
to google-ap...@googlegroups.com
Temple,

My mistake, the correct first version is:
gam user user...@domain.uk print filelist select id <Gfolderid> showownedby any id title filepath

Ross



--

Temple Rodgers

unread,
Sep 22, 2021, 11:04:26 AM9/22/21
to GAM for Google Workspace
Aha! Worked .. in my defence, I did search for ages to see what the correct identifier would be. thank you Ross.
Reply all
Reply to author
Forward
0 new messages