List of File Counts for Directories in a shared Google Drive

56 views
Skip to first unread message

qrob...@lotlinx.com

unread,
Sep 29, 2025, 9:13:40 AM (6 days ago) Sep 29
to GAM for Google Workspace
I have a shared Google Drive that has a directory in the root directory, and within that directory it contains a list of directories that I need to know the file count for

Example:
SharedDrive://MainFolder/Folder1
SharedDrive://MainFolder/Folder2
SharedDrive://MainFolder/Folder3
etc...

I need to know how many files are in each of the folders in MainFolder (file count for Folder1, Folder2, Folder3, etc)

I have been looking at the GAM documentation and I have been trying to use filecounts but it doesn't seem to be able to do what I want for this use case. I don't need to go too in depth with my file counts, depth 0 should suffice, I just want to know how many files are in the first level of each folder


So far I have done the below:
gam user em...@domain.tld print filetree select GOOGLEDRIVEUID depth 0 fields id

Which returns a csv of the folders in my MainFolder which shows the file name and the Google Drive file ID

This is where I am getting stuck. I have the list of Google Drive file ID's that I need file counts for, but I cannot seem to get a command to do this properly for this use case. The best I've come up with is using

gam user em...@domain.tld print diskusage GOOGLEDRIVEUID anyowner

Which gives me a list of files in the directory, but this takes forever (I was going to use the output from this to programmatically check how many results were returned).

Ross Scroggs

unread,
Sep 29, 2025, 11:25:18 AM (6 days ago) Sep 29
to google-ap...@googlegroups.com
Try this:

gam redirect csv ./TopFolders.csv user em...@domain.com print filelist select shareddriveid GOOGLEDRIVEUID showmimetype gfolder depth 0 fields id,name,mimetype

gam redirect csv ./TopFolderCounts.csv multiprocess csv TopFolders.csv gam user "~Owner" print filelist select "~id" depth 0 countsonly


Ross

----
Ross Scroggs



--
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 visit https://groups.google.com/d/msgid/google-apps-manager/873d1d26-964e-4bad-bfce-d6372a9a52ffn%40googlegroups.com.

qrob...@lotlinx.com

unread,
Sep 29, 2025, 12:07:12 PM (6 days ago) Sep 29
to GAM for Google Workspace
Thanks Ross.

It appears that the first command is getting all Drive Files/Folders for the user account or it's getting everything in the drive itself? I stopped the command because the results weren't going to be what was expected

PS C:\GAM7> gam redirect csv ./TopFolders.csv user em...@domain.tld print filelist select shareddriveid SHAREDDRIVEID showmimetype gfolder depth 0 fields id,name,mimetype
Getting all Drive Files/Folders for em...@domain.tld
Got 25760 Drive Files/Folders for em...@domain.tld  ...

Ross Scroggs

unread,
Sep 29, 2025, 12:09:22 PM (6 days ago) Sep 29
to google-ap...@googlegroups.com
Send me a private Meet/Zoom and we'll investigate

Ross
----
Ross Scroggs


Ross Scroggs

unread,
Sep 29, 2025, 12:16:36 PM (6 days ago) Sep 29
to google-ap...@googlegroups.com
What is: gam version

The output should start like this:

$ gam redirect csv ./TopFolders.csv user us...@domain.com print filelist select shareddriveid 0AAPOp4H7FOVaUkWXYZ showmimetype gfolder depth 0 fields id,name,mimetype

Getting all Drive Files/Folders for us...@domain.com on Shared Drive ID: 0AAPOp4H7FOVaUkWXYZ


Ross

----
Ross Scroggs


qrob...@lotlinx.com

unread,
Sep 29, 2025, 12:50:06 PM (6 days ago) Sep 29
to GAM for Google Workspace
Reply all
Reply to author
Forward
0 new messages