LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   'file -bi' and custom mime types (https://www.linuxquestions.org/questions/linux-general-1/file-bi-and-custom-mime-types-865847/)

ewsmith 03-01-2011 09:42 PM

'file -bi' and custom mime types
 
i have created a custom mime type.
the mime type is based on the file name (one letter followed by four numbers and then one letter ie: a1234b)
file browsers (like thunar, rox-filer, and dolphin) recognize it, but 'file -bi' does not.

is there something i can do to rectify this?

SOLUTION:
my mimetype is based off the file name but 'file -bi' is based off the contents.
so 'file -bi' will not detect the file as the custom mimetype.

A.Thyssen 03-02-2011 06:29 PM

I can find no reference to -bi option for find.
And even trying to use it fails.
Code:

find -bi *
find: unknown predicate `-bi'

I assume you mean "file" not "find"


However taking a step back. The two while related, have very different meanings.

"file" determines what a file is based on its contents. It can use file suffixes, but generally tryes to ignore any such suffixes or other preconceptions about a file. Its results are generally nothing to to with a files "mime" type.

A files "mime-type" is simply a method of telling a client (recieving) program what type of file it is, which it then uses to determine how to handle (display, process, execute) the file. It does not actually need to match up with the actual contents of a file!

For example you have a file of plain ASCII numbers. "file" will tell you it is plain ASCII text, it may even tell you it only consists of numbers. But that is all. The "mime" type however can tell a client that it is just text (as "file" with indicate) 'plain/text', or just a save file, 'application/octectstream', or perhaps a image saves as ascii numbers 'image/x-rgbtext' It can be ANY of those things.

Really the two are very different things.


However you can make "file" recognise files by its content by adding rules to the file "magic" file. see the "file" manpage. It is not a simple file to edit, but it is possible to make "file" recognise the data in the file.

ewsmith 03-02-2011 08:08 PM

-facepalm-
yes, i meant file :\

i didn't know that it was based off the contents... thanks for the info :D

i'll look up this magic file.

EDIT:
fyi, im dyslexic when typing...

A.Thyssen 03-02-2011 08:31 PM

hey so am I..

Hmm on my linux system the magick was located in (via a symbolic link)
/usr/share/magic

The type: man magic
for information as it its format.


All times are GMT -5. The time now is 06:51 AM.