How to find a file's mailcap "content type"?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to find a file's mailcap "content type"?

Chris Green
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.

For example there don't seem to be single, obvious entries for MS Word
.doc or .docx files.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to find a file's mailcap "content type"?

Peter Flynn
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

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.

Peter

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to find a file's mailcap "content type"?

Chris Green
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

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to find a file's mailcap "content type"?

Colin Watson
In reply to this post by Chris Green
On Mon, Oct 28, 2019 at 09:55:59PM +0000, Chris Green wrote:
> How can one find what mailcap "content type" corresponds to a file's
> actual format?

  file --brief --mime-type FILE-NAME

--
Colin Watson                                       [[hidden email]]

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to find a file's mailcap "content type"?

Chris Green
On Wed, Oct 30, 2019 at 10:59:43AM +0000, Colin Watson wrote:
> On Mon, Oct 28, 2019 at 09:55:59PM +0000, Chris Green wrote:
> > How can one find what mailcap "content type" corresponds to a file's
> > actual format?
>
>   file --brief --mime-type FILE-NAME
>
Of course, the 'file' command (which I use quite a lot for other
things), thank you Colin.  :-)

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users