Rename Label

169 views
Skip to first unread message

Joshua Adair

unread,
Mar 9, 2018, 12:42:38 PM3/9/18
to GAM for G Suite

I noticed a function in the code that seems to scan a user's labels and fix the Inbox/ nesting issue that frequently results due to migrating to Google Apps from a legacy email system. I didn't notice any documentation in the Wiki, so I wanted to come here to inquire about using this functionality. I've attached a screenshot showing the respective code as well.

Thanks!
Capture.PNG

Ross Scroggs

unread,
Mar 9, 2018, 1:22:59 PM3/9/18
to google-ap...@googlegroups.com
Joshua,

What are you trying to accomplish? Here is the command syntax.

gam <UserTypeEntity> update label search <RegularExpression> replace <LabelReplacement> [merge]


At it's simplest, <RegularExpression> is the old label name, and <LabelReplacement> is the new label name.
To change the label "Foo" to a new label "Bar" (the label "Bar" must not already exist):
gam user us...@domain.com update label search "Foo" replace "Bar"

If there is any chance that "Foo" may appear in the middle of a label, you can anchor the search <RegularExpressions>
with ^ and $ so that only "Foo" exactly matches.
gam user us...@domain.com update label search "^Foo$" replace "Bar"

To change the label "Foo" to an existing label "Bar", use the merge option.
gam user us...@domain.com update label search "^Foo$" replace "Bar" merge

If you want to use part of an old label name in the new label name, you isolate the portion of the old label name you want to keep
and indicate in the new label name where the isolated portion goes. In search <RegularExpression> there should be one instance of a
parenthesized expression, e.g., (.*). In replace <String>, %s indicates where the isolated portions goes.
gam user us...@domain.com update label search "^INBOX/(.*)$" replace "O365/%s"

Ross


On Fri, Mar 9, 2018 at 9:35 AM, Joshua Adair <joshua.s...@gmail.com> wrote:

I noticed a function in the code that seems to scan a user's labels and fix the Inbox/ nesting issue that frequently results due to migrating to Google Apps from a legacy email system. I didn't notice any documentation in the Wiki, so I wanted to come here to inquire about using this functionality. I've attached a screenshot showing the respective code as well.

Thanks!

--
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.
To post to this group, send email to google-apps-manager@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/3e17306a-d22e-4e3f-8c84-ae4218888e4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Joshua Adair

unread,
Mar 14, 2018, 10:15:27 AM3/14/18
to GAM for G Suite
Thank you so much Ross. Basically, I'm trying to "cleanup" label names after a migration, and I have the typical issues of the legacy folder names being "migrated" with Inbox/ as the top level folder. As a result, user labels look like:

Inbox/Followup
Inbox/Projects
Inbox/Receipts

I basically want to remove "Inbox/" from every label and sublabel in a way that also preserves the proper nesting structure. Your feedback gets me there, and I've been able to confirm results with a few tests. I also found the following post by you that helped:


Thanks again!

On Friday, March 9, 2018 at 1:22:59 PM UTC-5, Ross Scroggs wrote:
Joshua,

What are you trying to accomplish? Here is the command syntax.

gam <UserTypeEntity> update label search <RegularExpression> replace <LabelReplacement> [merge]


At it's simplest, <RegularExpression> is the old label name, and <LabelReplacement> is the new label name.
To change the label "Foo" to a new label "Bar" (the label "Bar" must not already exist):
gam user us...@domain.com update label search "Foo" replace "Bar"

If there is any chance that "Foo" may appear in the middle of a label, you can anchor the search <RegularExpressions>
with ^ and $ so that only "Foo" exactly matches.
gam user us...@domain.com update label search "^Foo$" replace "Bar"

To change the label "Foo" to an existing label "Bar", use the merge option.
gam user us...@domain.com update label search "^Foo$" replace "Bar" merge

If you want to use part of an old label name in the new label name, you isolate the portion of the old label name you want to keep
and indicate in the new label name where the isolated portion goes. In search <RegularExpression> there should be one instance of a
parenthesized expression, e.g., (.*). In replace <String>, %s indicates where the isolated portions goes.
gam user us...@domain.com update label search "^INBOX/(.*)$" replace "O365/%s"

Ross

On Fri, Mar 9, 2018 at 9:35 AM, Joshua Adair <joshua.s...@gmail.com> wrote:

I noticed a function in the code that seems to scan a user's labels and fix the Inbox/ nesting issue that frequently results due to migrating to Google Apps from a legacy email system. I didn't notice any documentation in the Wiki, so I wanted to come here to inquire about using this functionality. I've attached a screenshot showing the respective code as well.

Thanks!

--
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.
To post to this group, send email to google-ap...@googlegroups.com.



--

Graham Ingleby

unread,
Mar 23, 2018, 5:46:43 AM3/23/18
to GAM group
Hi Joshua

The command you want is
gam user user...@hackney.gov.uk update label merge

The merge option will combine the content of inbox/label with label if it already exists

Anyone can edit the Wiki to correct any errors or add missing commands etc

Regards
Graham

 


Graham Ingleby  |  Google Cloud Consultant  |  +44 1344 203395  |  ging...@ancoris.com
             
Twitter Google+ LinkedIn YouTube Ancoris 

Subscribe to our blog and receive our latest articles straight to your inbox

Ancoris receives Computing Cloud Excellence Award

Powered by Ancoris Signatures


Thanks again!
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsubscribe...@googlegroups.com.



--

--
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.
To post to this group, send email to google-apps-manager@googlegroups.com.

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



This message is for the named person's use only. If you receive this message in error, please delete it and notify the sender. Ancoris reserves the right to monitor all e-mail communications through its networks. Ancoris Limited, Registered in England Number: 04830784, Registered address: 5a Frascati Way, Maidenhead, Berkshire SL6 4UY. Trading Address: Lily Hill House, Lily Hill Road, Bracknell, Berkshire RG12 2SJ




Reply all
Reply to author
Forward
0 new messages