MU-EXTRACT(1)

πŸ’Œ MU-EXTRACT(1) β€” the "get ur attachments outta that email" page

ok so real talk, this lives in the General Commands Manual section of mu(1), and it's genuinely one of the most useful little gremlins in the whole toolbox. buckle up bestie πŸŽ€


✨ NAME ✨

mu-extract β€” display and save message parts (attachments), and open them with other tools.

πŸ“œ SYNOPSIS πŸ“œ

mu [COMMON-OPTIONS] extract [OPTIONS] [FILE]

mu [COMMON-OPTIONS] extract [OPTIONS] FILE PATTERN

πŸ¦‹ DESCRIPTION πŸ¦‹

so mu extract is the mu sub-command that pulls MIME-parts (think: attachments, the good stuff) out of mail messages. it works straight on message files, which means the message does NOT need to be indexed in the database first. no database era required, we love a low-maintenance queen πŸ’…

for attachments, the file name it saves under is literally the name of the attachment inside the message. if there's no such name, or if you're saving non-attachment MIME-parts, then a name gets derived from the message-id of the message. so it always gives you something to call it, periodt.

if you pass a regular expression pattern as the second argument, every attachment whose filename matches that pattern gets extracted. the regexes are basic PCRE, and they're case-sensitive by default β€” go read pcre(3) for the full tea.

with no options at all, mu extract just prints out the list of leaf MIME-parts in the message. and listen β€” only "leaf" MIME-parts count, and that includes RFC822 attachments. multipart/* and friends? ignored. they're not the moment, they're just the packaging πŸ“¦

if you don't give a filename parameter, mu extract reads the message from standard input. and in THAT case you cannot use the second, PATTERN parameter, because that would be ambiguous β€” instead use the --matches option. iykyk ✨

πŸŽ€ EXTRACT OPTIONS πŸŽ€

  • -a, --save-attachments β€” save all the MIME-parts that look like attachments. the classics, the icons.
  • --save-all β€” save all non-multipart MIME-parts. everything, no gatekeeping.
  • --parts parts β€” only consider the following numbered parts (a comma-separated list, bestie). you can see the numbers for the parts by running mu extract with no options but only the message file. peek first, then cherry-pick πŸ“
  • --target-dir dir β€” save the parts into dir instead of the current working directory.
  • --overwrite β€” overwrite existing files with the same name. by default overwriting is not allowed, so don't come crying if you didn't ask for this 😭
  • -u,--uncooked β€” by default mu transforms the attachment filenames a bit (like, replacing spaces with dashes, the way it does); with this option, it leaves that to the bare minimum needed to create a legal filename in the target directory. raw-ish, unseasoned, still legal.
  • --matches pattern β€” attachments with filenames matching pattern will be extracted. same deal as before: basic PCRE, case-sensitive by default, see pcre(3) for more.
  • --play β€” try to "play" (open) the attachment with the default application for that particular file type. on MacOS this uses the open program; on other platforms it uses xdg-open. you can pick a different program by setting the MU_PLAY_PROGRAM environment variable. main character energy for your mp3s fr fr 🎧

🌸 COMMON OPTIONS 🌸

  • -d, --debug β€” makes mu generate extra debug info, which is handy for debugging the program itself. debug info goes to the standard logging location; peep mu(1) for that.
  • -q, --quiet β€” makes mu not output informational messages and progress info to standard output, only to the log file. error messages will still go to standard error. fyi mu index is much faster with --quiet, so the recommendation is to use this when you're calling mu from scripts etc. speed + silence = slay πŸš€
  • --log-stderr β€” makes mu not output log messages to standard error, in addition to sending them to the standard logging location.
  • --nocolor β€” don't use ANSI colors. the environment variable NO_COLOR can be used as an alternative to --nocolor. sometimes you just want monochrome vibes πŸ–€
  • -V, --version β€” prints mu version and copyright information.
  • -h, --help β€” lists the various command line options.

⭐ EXAMPLES ⭐

to display information about all the MIME-parts in a message file:

$ mu extract msgfile

to extract MIME-part 3 and 4 from this message, overwriting existing files with the same name:

$ mu extract --parts=3,4 --overwrite msgfile

to extract all files ending in .jpg (case-insensitive):

$ mu extract msgfile '.*\.jpg'

to extract an mp3-file, and play it in the default mp3-playing application:

$ mu extract --play msgfile 'whoopsididitagain.mp3'

when reading from standard-input, you need --matches, so:

$ cat msgfile | mu extract --play --matches 'whoopsididitagain.mp3'

πŸ’€ REPORTING BUGS πŸ’€

found a bug? please report it at https://github.com/djcb/mu/issues. don't be shy, the maintainers wanna know πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>

this manpage is part of mu 1.14.2.

Copyright Β© 2008-2026 Dirk-Jan C. Binnema. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html. this is free software: you are free to change and redistribute it. there is NO WARRANTY, to the extent permitted by law. read that again bestie, NO WARRANTY, no cap πŸ”₯

🌈 SEE ALSO 🌈


ok that's the whole page!! this is MU EXTRACT(1) from the General Commands Manual, part of mu 1.14.2 β€” go forth and liberate ur attachments, you absolute icon πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from