How to find a file's mailcap "content type"?
Chris Green
cl at isbd.net
Mon Oct 28 22:38:19 UTC 2019
On Mon, Oct 28, 2019 at 10:20:06PM +0000, Peter Flynn wrote:
> On 28/10/2019 21:55, Chris Green wrote:
> > How can one find what mailcap "content type" corresponds to a file's
> > actual format?
> >
> > Some are quite obvious as the default file type suffix matches the
> > seconds field of the mailcap content type, but this isn't always so.
>
> You mean like application/pdf? That's not a reliable guide.
>
> > For example there don't seem to be single, obvious entries for MS Word
> > .doc or .docx files.
>
> My /etc/mailcap contains the two single entries:
>
> >> grep '%s\.doc[x]*$' /etc/mailcap
> > > application/vnd.openxmlformats-officedocument.wordprocessingml.document;
> soffice --nologo --writer '%s'; edit=soffice --nologo --writer '%s';test=test
> -n "$DISPLAY"; description="Office Open XML Document";nametemplate=%s.docx
>
> > > application/msword; soffice --nologo --writer '%s'; edit=soffice --nologo
> --writer '%s'; test=test -n "$DISPLAY"; description="Microsoft Word Document";
> nametemplate=%s.doc
>
So can one rely on the nametemplate field if there's not a match on
the second part of the content type?
> See RFC 6838 (Media Type Registration) January 2013, section 3.2 Vendor Tree
> for details of how commercial and industrial vendor-related products are
> registered using the "vnd." facet.
>
> In the case of Microsoft Office Open XML (MS-Office) and OASIS OpenDocument
> XML (eg LibreOffice) file formats (and others) the picture is muddied by the
> fact that the file format is actually ZIP, but the documents are typically
> opened using application products.
>
Yes, I know .docx is a compressed format but if I want to write a
custom handler for (for example) .docx what do I put in my local
~/.mailcap file? Is something like:-
application/vnd.openxmlformats-officedocument.wordprocessingml.document myscript.sh %s
going to hand .docx files to myscript.sh?
(I already have custom scripts handling PDF and JPG files)
--
Chris Green
More information about the ubuntu-users
mailing list