34

I am looking for a way to select multiple messages in Mutt.

For example selecting the first and the last message would select a whole block of messages. I'd also like to select a subject using a regular expression.

Then, I want to run a command on the selected messages, i.e. save them to a file.

47

You need to run the tag-pattern command. The default for that is T (Shift+t). You can then give it a regular expression. By default this will match message subjects.

If you need to select a range of messages by number, you can provide the ~m [MIN]-[MAX] pattern to tag-pattern. There are many other options I've found useful over the years, and you can see a complete list in the “Advanced Usage - Patterns” section of the manual.

You can also use t to tag or untag the highlighted message, to fine-tune the selection.

Then you can run tag-prefix (;) followed by save-message (s), and it will prompt you for a mailbox name. This command marks the saved messages to be deleted; there is also the copy-message command (C, i.e. Shift+c) to copy without marking for deletion.

  • 3
    to select all: T then dot (.) – tutuDajuju Sep 1 '15 at 6:33
  • 2
    If you want to delete multiple messages based on a pattern, you can hit D and then type a pattern (like spam@spam.spa). Then quit and purge. – bonh Dec 21 '17 at 20:46
6

Extending @Scott McClung's correct answer:

If you want to apply mutt commands by default to all selected (tagged) messages without using tag-prefix (bound to ; by default), you can set the auto_tag variable by adding this line to your .muttrc:

set auto_tag = true
  • true was not accepted by my mutt version 1.10.1 and it pointed out that values should either be yes or no. would edit it but it's too short of an edit for SE to accept it. – user640916 Jan 16 at 21:11
4

Check also http://www.sendmail.org/~ca/email/mutt/manual-4.html + http://www.rosipov.com/blog/effective-search-with-mutt/ for useful flags like ~d 31/12/99-01/01/00 ~s Y2K ~b scared.

L uses the same syntax to browse only a subset of your inbox, eg ~f moms.email@debian.org ~B your father.

  • loved the samples :-) – Gen.Stack Feb 20 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy