mu/man/mu-extract.1.org

109 lines
3.4 KiB
Org Mode
Raw Permalink Normal View History

#+TITLE: MU EXTRACT
#+MAN_CLASS_OPTIONS: :section-id "@SECTION_ID@" :date "@MAN_DATE@"
* 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
*mu extract* is the *mu* sub-command for extracting MIME-parts (e.g., attachments)
from mail messages. The sub-command works on message files, and does not require
the message to be indexed in the database.
For attachments, the file name used when saving it is the name of the attachment
in the message. If there is no such name, or when saving non-attachment
MIME-parts, a name is derived from the message-id of the message.
If you specify a regular express pattern as the second argument, all attachments
with filenames matching that pattern will be extracted. The regular expressions
are basic PCRE, and are case-sensitive by default; see *pcre(3)* for more details.
Without any options, *mu extract* simply outputs the list of leaf MIME-parts in
man: change quoting style The man-page sources use single quotes to quote text. However, this can be problematic in man-pages because if a single quote appears at the beginning of a line the following word is interpreted by troff as a macro. For example, this paragraph in mu-easy.7: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will 'summarize' the first \fIn\fP lines of the message: elicits this warning: $ man --warnings obj-x86_64-linux-gnu/man/mu-easy.7 >/dev/null troff:<standard input>:166: warning: macro 'summarize'' not defined and gets truncated: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the --summary-len op‐ tion, which will One could adjust the line-wrapping to move the quoted text away from the beginning of the line, but that is fragile. Another possibility would be to use the troff escape-sequences for open and close quotes (`\(oq` and `\(cq` respectively), but ox-man is being used precisely to avoid having to handle troff directly. Instead use back-ticks for left quotes. Thus: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will `summarize' the first \fIn\fP lines of the message: which is rendered correctly: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the --summary-len op- tion, which will `summarize' the first n lines of the message: Signed-off-by: Jeremy Sowden <azazel@debian.org>
2024-03-02 14:25:56 +01:00
the message. Only `leaf' MIME-parts (including RFC822 attachments) are
considered, *multipart/** etc. are ignored.
Without a filename parameter, ~mu extract~ reads a message from standard-input. In
that case, you cannot use the second, ~<pattern>~ parameter as this would be
ambiguous; instead, use the ~--matches~ option.
* EXTRACT OPTIONS
** -a, --save-attachments
save all MIME-parts that look like attachments.
** --save-all
save all non-multipart MIME-parts.
** --parts=<parts>
only consider the following numbered parts (comma-separated list). The numbers
for the parts can be seen from running *mu extract* without any options but only
the message file.
** --target-dir=<dir>
save the parts in the target directory rather than the current working
directory.
** --overwrite
overwrite existing files with the same name; by default overwriting is not
allowed.
** -u,--uncooked
by default, ~mu~ transforms the attachment filenames a bit (such as by replacing
spaces by dashes); with this option, leave that to the minimum for creating
a legal filename in the target directory.
** --matches=<pattern>
Attachments with filenames matching the pattern will be extracted. The regular
expressions are basic PCRE, and are case-sensitive by default; see *pcre(3)* for
more details.
** --play
man: change quoting style The man-page sources use single quotes to quote text. However, this can be problematic in man-pages because if a single quote appears at the beginning of a line the following word is interpreted by troff as a macro. For example, this paragraph in mu-easy.7: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will 'summarize' the first \fIn\fP lines of the message: elicits this warning: $ man --warnings obj-x86_64-linux-gnu/man/mu-easy.7 >/dev/null troff:<standard input>:166: warning: macro 'summarize'' not defined and gets truncated: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the --summary-len op‐ tion, which will One could adjust the line-wrapping to move the quoted text away from the beginning of the line, but that is fragile. Another possibility would be to use the troff escape-sequences for open and close quotes (`\(oq` and `\(cq` respectively), but ox-man is being used precisely to avoid having to handle troff directly. Instead use back-ticks for left quotes. Thus: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will `summarize' the first \fIn\fP lines of the message: which is rendered correctly: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the --summary-len op- tion, which will `summarize' the first n lines of the message: Signed-off-by: Jeremy Sowden <azazel@debian.org>
2024-03-02 14:25:56 +01:00
Try to `play' (open) the attachment with the default application for the
particular file type. On MacOS, this uses the *open* program, on other platforms
it uses *xdg-open*. You can choose a different program by setting the
*MU_PLAY_PROGRAM* environment variable.
#+include: "common-options.inc" :minlevel 1
* EXAMPLES
To display information about all the MIME-parts in a message file:
#+begin_example
$ mu extract msgfile
#+end_example
To extract MIME-part 3 and 4 from this message, overwriting existing files with
the same name:
#+begin_example
$ mu extract --parts=3,4 --overwrite msgfile
#+end_example
man: change quoting style The man-page sources use single quotes to quote text. However, this can be problematic in man-pages because if a single quote appears at the beginning of a line the following word is interpreted by troff as a macro. For example, this paragraph in mu-easy.7: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will 'summarize' the first \fIn\fP lines of the message: elicits this warning: $ man --warnings obj-x86_64-linux-gnu/man/mu-easy.7 >/dev/null troff:<standard input>:166: warning: macro 'summarize'' not defined and gets truncated: What if we want to see some of the body of the message? You can get a 'summary' of the first lines of the message using the --summary-len op‐ tion, which will One could adjust the line-wrapping to move the quoted text away from the beginning of the line, but that is fragile. Another possibility would be to use the troff escape-sequences for open and close quotes (`\(oq` and `\(cq` respectively), but ox-man is being used precisely to avoid having to handle troff directly. Instead use back-ticks for left quotes. Thus: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the \fI\-\-summary\-len\fP option, which will `summarize' the first \fIn\fP lines of the message: which is rendered correctly: What if we want to see some of the body of the message? You can get a `summary' of the first lines of the message using the --summary-len op- tion, which will `summarize' the first n lines of the message: Signed-off-by: Jeremy Sowden <azazel@debian.org>
2024-03-02 14:25:56 +01:00
To extract all files ending in `.jpg' (case-insensitive):
#+begin_example
$ mu extract msgfile '.*\.jpg'
#+end_example
To extract an mp3-file, and play it in the default mp3-playing application:
#+begin_example
$ mu extract --play msgfile 'whoopsididitagain.mp3'
#+end_example
when reading from standard-input, you need ~--matches~, so:
#+begin_example
$ cat msgfile | mu extract --play --matches 'whoopsididitagain.mp3'
#+end_example
#+include: "prefooter.inc" :minlevel 1
* SEE ALSO
*mu(1)*