Create Gmail labels and apply them to existing emails in batch. Use when organizing past emails or setting up label taxonomy. Supports full Gmail search syntax for targeting specific emails.
Create labels and batch-apply them to existing emails.
Syntax: /gmail-label create <name>
Examples:
/gmail-label create Newsletters
/gmail-label create "Work/Projects"
/gmail-label create "Finance/Invoices"
Syntax: /gmail-label list
Shows all labels with IDs.
Syntax: /gmail-label apply "<search-query>" <label>
Examples:
/gmail-label apply "from:@github.com newer_than:30d" Notifications
/gmail-label apply "from:[email protected]" Newsletters
/gmail-label apply "subject:invoice" "Finance/Invoices"
Syntax: /gmail-label delete <label-name>
gog gmail labels list --json
Search for existing label with same name.
gog gmail labels create "LabelName"
For nested labels, use forward slash:
gog gmail labels create "Parent/Child"
## Label Created
**Name**: Newsletters
**ID**: Label_123456789
Use this label with:
- `/gmail-filter create @domain.com Newsletters`
- `/gmail-label apply "from:@domain.com" Newsletters`
gog gmail labels list --json
Format as table:
| Name | ID | Type |
|---|---|---|
| Newsletters | Label_123 | user |
| Work | Label_456 | user |
| INBOX | INBOX | system |
Test the query first:
gog gmail search '<query>' --json | head -5
Show count: "Found X emails matching query"
gog gmail labels list --json
Find label ID by name.
For each matching email:
gog gmail modify <message-id> --add-label <label-id>
Note: Process in batches of 50 for efficiency.
## Labels Applied
**Query**: from:@github.com newer_than:30d
**Label**: Notifications
**Emails Modified**: 47
Sample of labeled emails:
- "[GitHub] Pull request #123..." (Jan 25)
- "[GitHub] Issue comment on..." (Jan 24)
- ...
# Get label ID first
gog gmail labels list --json
# Delete by ID
gog gmail labels delete <label-id>
Warning: Deleting a label removes it from all emails.
Use / for nested labels:
Work/ProjectsWork/ClientsFinance/InvoicesFinance/ReceiptsWork/
├── Projects
├── Clients
└── Internal
Personal/
├── Family
└── Friends
Finance/
├── Invoices
├── Receipts
└── Statements
Newsletters/
├── Tech
├── News
└── Other
Notifications/
├── GitHub
├── Slack
└── Calendar
| Description | Query |
|---|---|
| From domain | from:@github.com |
| Last 30 days | newer_than:30d |
| Unread only | is:unread |
| With attachments | has:attachment |
| Subject contains | subject:invoice |
| Combined | from:@amazon.com subject:order newer_than:60d |