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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mime-extension-1.1.0.tar.gz.
File metadata
- Download URL: mime-extension-1.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dcb14e2fcaee9d8ce0b0d6860dbf4b08ac046889b8b3f2de74f401a3ade561d
|
|
| MD5 |
b930477cc5f239f5cb3af123d506d9c2
|
|
| BLAKE2b-256 |
5acb31734e9467af1dd71ad501edee9cef7c92d4798b4ab1e63a5158c16b897a
|