897 views


You can use the following shell command to get a file’s MIME type:

file --mime-type -b Downloads/main.js # text/plain file --mime-type -b Downloads/logo.jpg # image/jpeg

It’s important to use the brief (-b) option in the command or you may receive an error message.< Luckily the file command and and a flag is all you need!

The post Get File MIME Type from Command Line appeared first on David Walsh Blog.[From Line Dark Mode Mac Command]

.I love a good GUI but knowing how to automate makes you a much more powerful engineer. Much of my scripting requires recursing over directories and processing a file if it meets a given criteria, which is often file extension or MIME type.

MIME type is used for validation and any number of other informational use cases.

I’ve gotten skilled at shell scripting over the years.[To Top Development Consider Tools 3 Cross Platform]
Source: https://davidwalsh.name/get-mime-type

Comments
No comments yet. Be first to leave one!