OSX: assign extension to content kind

You need to use an application that declares the correct file type association for e.g. the .mkv file name extension.

For example, the system-defined file types in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist declare the following in the Exported Type UTIs section:

enter image description hereenter image description here

This allows the system to associate the UTI public.jpeg with the "UTI group" public.image, which is (very likely) what Finder uses for the Images group; the public.filename-extensions equivalent type maps to the file extension.

This allows OS X to determine, that .jpg file has the UTI public.jpeg, and that is a sub-UTI of public.image (and so on, with public.item and public.data). Finder then takes all the files that are (also) public.image and puts them in the same Images group.

The same applies to public.mpeg-4 and public.movie and the filename mapping there.


Unfortunately, the author of MPlayerX didn't bother mapping the UTIs.

He didn't even bother creating proper file types for all the extensions the program supports. That's why in Finder's list view, all .mkv files aren't called e.g. Matroska Video, and have a matching MKV label on their icon, but simply Video Media with a generic Video label. All supported file types are listed by file extension for this "file format", so MPlayerX can open them:

enter image description here

That means, for example, if you prefer playing .m4a files in MPlayerX to iTunes, you lose the descriptive Apple MPEG-4 audio in the Finder's Kind column and get Audio Media instead.


You can fix the grouping by editing the /Applications/MPlayerX.app/Contents/Info.plist file and properly declaring e.g. a mplayerx.video UTI that conforms to public.movie and adding the proper filename extension mapping.

You can fix the Kind column by editing the same file, and properly declaring file types with a better description, and creating an icon file for each.

Just use the Core Types Info.plist file as template, replacing e.g. public.jpeg with your own custom identifier (e.g. mplayerx.video if you don't want proper Kind columns and icons, or mplayerx.mkv if you want them). You need Xcode to edit these files, or convert them to XML editable in any text editor by using plutil -convert xml1 <filename>.

Your changes, which are rather easy to get wrong, will be overridden with every application update.

Alternatively, at least for the Finder Arrange By Kind, you can edit the core types definitions and add your own to it. Make sure to edit a copy of the file and replace it after editing to circumvent permissions issues. Be aware that you'll be editing and replacing core system files (i.e. asking for trouble) by doing this.

A saner solution would be to create a new "dummy" application that simply declares the file type UTIs as Exported Type UTIs. This will be used by OS X's file type database and you can update both OS X and MPlayerX without losing the content type associations. Even if you change e.g. .m4a to MPlayerX, only the Kind column is changed, it's still in the Movie category, due to the declarations in another application independent of the associated application.

So, create a new application e.g. using Automator that doesn't actually do anything when launched, and add the following to its Contents/Info.plist file:

enter image description here

Save in /Applications or so, and restart Finder.

enter image description here

Partial mdls output of the .mkv file, content type provided by the "helper app", item kind provided by the associated player (MPlayerX):

kMDItemContentType             = "superuser.371939.mkv"
kMDItemContentTypeTree         = (
    "superuser.371939.mkv",
    "public.movie",
    "public.audiovisual-content",
    "public.data",
    "public.item",
    "public.content"
)
...
kMDItemKind                    = "Video Media"

Since this is just sloppy platform integration by the developer, you should probably file a bug.