Number of labels per message

262 views
Skip to first unread message

S Simon

unread,
Jun 16, 2021, 1:09:40 PM6/16/21
to GAM for Google Workspace
We are looking at whether users tend to treat labels as folders (i.e. one-to-one) or as tags (assigning multiple labels to a single message) in preparation for a potential migration project.

I see I can get a list of labels for an individual message using show labels but wondering if anyone has a script to aggregate this info? (I've found a few discussions about the opposite scenario - number of messages per label but none about the (aggregate/average) number of labels per message.

Many thanks!

Peter Smulders

unread,
Jun 23, 2021, 5:07:17 AM6/23/21
to GAM for Google Workspace
This will do it:

gam user us...@yourdomain.com print messages max_to_print 2 showlabels | cut -d',' -f12 | while read LINE; do echo $LINE | wc -w; done | sort -n

Obviously set the max_to_print to where you want or leave it out altogether. This wil get you a long list of sorted numbers, which you can then analyze for your purposes. Alternatives:

gam user us...@yourdomain.com print messages max_to_print 2 showlabels | cut -d',' -f12 | while read LINE; do echo $LINE | wc -w; done | sort -u

will give you just the unique numbers, most likely a sorted list from 0 to the maximum of labels someone has used.

gam user us...@yourdomain.com print messages max_to_print 2 showlabels | cut -d',' -f12 | while read LINE; do echo $LINE | wc -w; done | sort -u | tail -1

will give you the maximum amount of labels used on a single message in the sample.

This is a bit rough but it will work. If you want, you could loop it through a number of users to get a better view. It will take more time with more users, obviously:

gam print users |  tail +2 | while read USER; do
gam user ${USER} print messages showlabels | cut -d',' -f12 | while read LINE; do echo $LINE | wc -w; done | sort -u | tail -1
done

This will produce a list of maximum per message label counts with one entry for every user.

hth -- Peter

S Simon

unread,
Feb 17, 2022, 12:33:53 AM2/17/22
to GAM for Google Workspace
Thanks so much Peter - I just stumbled across this and apologize I didn't notice it much sooner!! Luckily this process has dragged on, and this will be really useful for me. Much appreciated!

Ross Scroggs

unread,
Feb 17, 2022, 11:06:58 AM2/17/22
to google-ap...@googlegroups.com
Try this:

gam user us...@domain.com print messages countsonly showlabels useronly

This will show one line showing the number of user labels the user has and how many times each label has been used.

Ross
--
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/38615319-0cf3-4d45-8276-0c4218218548n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages