6 ms·
Show HN: Gmail CLI Utils (bulk delete mail by query, get/create filters)
- adamfeldman 6y agoThis looks useful! For "Declarative configuration for Gmail filters", see also https://github.com/mbrt/gmailctl https://github.com/mbrt/gmailctl
- aryamaan 6y agoThis is nice. A couple of days back I was thinking of a utility where labels are created automatically. It uses meta information like: * How many emails I get from a sender * From mails' subject * Which similar mails I open or not.
- jimbob45 6y agoI will be going to work tomorrow and baking this into our email test suite.
- harikb 6y agoRelated: would this tool let me analyze my gmail for cleanup? That is, identify which senders/domains send me the most email by number or size. Some way to automatically download large attachments and then deletes those. I know there are 3rd party apps that do this, but I don’t like giving access to random 3rd party apps.
- jedberg 6y agoI know this isn't exactly what you are looking for, but I run this search once every few months: [has:attachment larger:5M] That finds everything bigger than 5 megabytes. You can't sort by size, but at least you can find big stuff. If that search has too many results, just keep upping the number until you find the few really big messages.
- abionic 6y agosuggestion by @jedberg would work good for a search based on attachment size your suggestion on "auto analysis for cleanup" is good, I'll add it to my ToDo list
- harikb 6y agoThanks. Yes I know that search option, but sometimes 1 mb x 100 is sitting there while I take trouble locating a single 5 mb message.
- matlin 6y agoThis is sweet. If you're interested, I'd be happy to help out with your todo to integrate with a local database. Getting the rate-limiting and retries right can be a little tricky but it's been on my list to add Gmail support to AspenDB https://github.com/aspen-cloud/aspen-cli https://github.com/aspen-cloud/aspen-cli.
- abionic 6y agoany help is welcome, thanks
- gigatexal 6y agoMaybe this will help me get to a zero inbox finally. 65k emails 99% of which are junk.
- alfonsodev 6y agoSounds like you could benefit from enabling the category tabs feature in gmail, at least it will separate few categories for you
- jedberg 6y agoYou could try email bankruptcy. Just mark everything as read. If it's important, they'll send it again. I cheat by marking everything more than 30 days old as read. I do that once a year in February. I mark everything from the previous year as read on Feb 1. Sometimes I do it again in July/August.
- Freeboots 6y agoSame, I go even more ruthless. Any unread email over a week old gets marked read, any read email over a week old gets archived. All Updates, Social, Promotion emails get marked read on arrival. All Primary inbox emails get intercepted on arrival and batched back into inbox on a schedule (usually twice a day). I sit at zero most of the time, and ive only ever missed emails a bare handful of times, so seems to work.
- jedberg 6y agoHow do you batch the incoming emails into a few drops a day?
- Freeboots 6y agoI use a simple Apps Script. A filter adds a "New Messages" label to incoming "category:primary" and skips inbox, then the script on timer triggers remove the label and put them back in inbox https://github.com/MichaelYock/GmailScripts/blob/master/GmailBatch.gs https://github.com/MichaelYock/GmailScripts/blob/master/Gmai... Come to think of it, i was going to make a GUI for this now that gmail add-on Cards have a Home Card option
- rodcoelho 6y agoCreating this was on my to-do list this week. Ya beat me to it!
- abionic 6y ago:)
- lifeisstillgood 6y agoI did something similar - in fact looking at the add filter, very similar, where I add a label to certain mails by query and then delete - but the weirdest part was i could not auto-create one new filter - i have to re-create them all (so if I want to add a 21st filter with 20 still there my create filter routine needs to apply 21 filters. I just have it trying to reduce the spam and should spend some time trying to add new filters - one day. But this is cool and love to know if there is a "add one" feature i missed.
- abionic 6y agoI am using google-api-client, which has a "create" for single GMail Filter available here: https://developers.google.com/gmail/api/v1/reference/users/settings/filters https://developers.google.com/gmail/api/v1/reference/users/s...
- lifeisstillgood 6y agothanks i will have a look
- ronyeh 6y agoHow might I use this to delete emails with big attachments? Can I filter and delete by message size? I'm cheap. :-)
- xuhu 6y agoUse a filter like "has:attachment larger:10mb in:all". For each 100 deleted emails you get 1GB of free space back.
- notyourday 6y agoI know this is an odd question but... Have you tried deleting a very large number of messages? I am talking about > 100,000. I once needed to clean up > million messages and it was rather challenging even utilizing Google's scripting. Batching ( within Google's recommended parameters ) would periodically fail. Triggers would not run. etc.
- bishalb 6y agoYou can just Create a filter to delete such messages and check apply to all existing conversations.
- stevekemp 6y agoHaving gone through this recently you'll see a spinner/progress indicator. Then a short time later it'll terminate and half your messages will still be present. I took several days deleting a few hundred thousand messages, "Select all", "delete". Each time it would remove 1000-10,000 messages and leave the rest. Was a real pain.
- notyourday 6y agoAfter a lot of trial and error I have been successful at doing a limit fetch and limit delete with a limit of 9000 in 5 minute intervals using scripting API with a registering a timed trigger. 1. Get current time, increase the time by 5 minutes and find the 5 minute mark after that. 2. Register itself to run the time determined in (1). 3. Fetch a batch of 9000 ids matching the filter. 4. Delete the batch This script would comfortably run for days cleaning out the inbox until it would hit some weird message that looked nearly identical to the messages around it and bomb(!?). Running it by hand would bomb at which point script won't be able to continue to execute. Deleting a message by hand would work. Running the script again after the manual deletion would work.
- notyourday 6y agoMy first thought after "how hard can it be? Since all the messages are from the monitoring systems I can just assign the labels based on the 'from' address and..." was to use that exact approach. It have never seen that many timeouts in my life.
- stevekemp 6y agoSee also my little hack, a sort of procmail for gmail, with a small scripting language: https://github.com/skx/labeller/ https://github.com/skx/labeller/ Adding/Removing labels based upon arbitrary expressions/headers/values, etc.
- hugothefrog 6y agoHijacking this comment, but it seems likely to attract the right sort of crowd.. Can anyone recommend a Mac/web Gmail UI with exceptionally fast hotkey interactions? The Gmail web interface has slowed to the point of un-usability for me now. Command line (Alpine, etc) would be fine, but my Gmail account is secured by work and has the required access control settings disabled.
- throwaway_pdp09 6y agoUse the plain HTML interface (no JS) and it's very fast. The option to disable it is at the bottom. You can of course enable it any time.
- statictype 6y agoFWIW, I tried Superhuman for a month and it was exellent. Extremely fast and responsive shortcuts. 30 USD/month was a bit more than I can justify so I cancelled but I still wish I hadn't. Not sure what you meant by 'secured by work' - you can still authorize 3rd party apps can't you? Is it even possible to block that?
- hugothefrog 6y agoThat's an avenue I'm pursuing - have joined the waiting list and am waiting for someone to get back to me after a brief email interaction over the weekend. Secured by work was a reference to one possible suggestion of using Alpine or similar, which requires app-specific passwords. And yes, it seems it is possible to block that!
- njhaveri 6y agoI’m working on a native Mac email client for Gmail that uses the Gmail API and support Gmail-specific features like labels and categorized inboxes. If you’re able enable access for 3rd party apps, and interested in beta testing this, would love to have you sign up at https://mimestream.com https://mimestream.com
- Accacin 6y ago
- tleb_ 6y agoRelated: I recently used mbsync and notmuch to clean-up my Outlook/Live/Office email account. A one-liner to get email count per domain: notmuch address '*' | sed "s/^.*@//" | sed "s/>\$//" | sort | uniq > domains.txt To "delete" emails (move them to the deleted folder): notmuch search --output=files --format=text0 '(tag:whatever and not folder:Deleted' | xargs -0 --no-run-if-empty mv -t ~/.mail/live/Deleted/new/ Useful alternative to this for non-Gmail. The Outlook interface couldn't delete more than a few hundred mails.