Skip to main content

mime-extension

Find the file extensions associated with mime-type on a Linux systems.

Note that the reverse query - going from extension to mime-type can be achieved using the xdg-mime command-line tool. You can go from the contents of a file to a mime-type using the file command with file -b --mime-type $FILE.

Motivation

There appears to be no standard script to perform this function but a solution and script is provided on stack exchange by Kamil Maciorowski. I needed this functionality, and where possible I prefer my solutions to work on any computer and be easily installed so I am packaging this as a script.

Additionally, the solution in stack overflow is based upon /etc/mime.types but I think most desktop environmenets now use the XML files /usr/share/mime combined with ~/.local/share/mime for this information.

Installation

You can install mime-extension using pipx:

pipx install mime-extension

Usage

mime-extension text/html

Note that there are often multiple file extensions.

Support this tool

If you like this tool you could give me money ($1 maybe) on my ko-fi.

You could also look at some of the other command-line tools I have created.

About me

I am @readwithai I make tools for reading, research and agency often using Obsidian.

I also produce a stream of tools related to the work I do on this.

You can follow me on X or my blog blog.

Metadata

Release files for mime-extension 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mime-extension 1.1.0
File Size Uploaded Provenance Actions
mime-extension-1.1.0.tar.gz 3.2 kB Without provenance Details for mime-extension-1.1.0.tar.gz

Release files / mime-extension-1.1.0.tar.gz

Download URL mime-extension-1.1.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7dcb14e2fcaee9d8ce0b0d6860dbf4b08ac046889b8b3f2de74f401a3ade561d
BLAKE2b-256 checksum
How to use checksums
5acb31734e9467af1dd71ad501edee9cef7c92d4798b4ab1e63a5158c16b897a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Security for mime-extension 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page