macOS

Duti - File Association Tool

What is Duti

Duti by Andrew Mortensen is a very handy and easy to use tool. Its very useful to setup newly formatted systems or when moving from one app to another.

Imagine the scenario: you use Quicktime to watch all your movies , but now you want to try out VLC for some time. After all it is lighter faster and it has more features.

All you need to do to associate all media files with VLC is to edit a text file with some settings and use duti to execute them. And just like that all the media files will now play with another player. Very useful, and handy!

Duti can read settings from a plain command text file or from a xml file.

You can download duti's source code here: https://github.com/moretension/duti

Alternatively you can install it with Homebrew

brew install duti

Settings File (duti.conf)

Any name will do for this file.

#  BUNDLE ID          UTI/EXT/MIME TYPE      ROLE

#  Text Editor - Sublime 3

com.sublimetext.3             .c             all
com.sublimetext.3             .js            all
com.sublimetext.3             .conf          all
com.sublimetext.3             .cfg           all
com.sublimetext.3             .ini           all
com.sublimetext.3             .json          all
com.sublimetext.3             .jsp           all
com.sublimetext.3             .js            all
com.sublimetext.3             .java          all
com.sublimetext.3             .scss          all
com.sublimetext.3             .css           all
com.sublimetext.3             .sql           all
com.sublimetext.3             .sqlite        all
com.sublimetext.3             .mysql         all
com.sublimetext.3             .txt           all
com.sublimetext.3             .less          all
com.sublimetext.3             .src           all
com.sublimetext.3             .cmd           all
com.sublimetext.3             .hta           all
com.sublimetext.3             .lua           all
com.sublimetext.3             .m             all
com.sublimetext.3             .m4            all
com.sublimetext.3             .h             all
com.sublimetext.3             .php           all
com.sublimetext.3             .pl            all
com.sublimetext.3             .pm            all
com.sublimetext.3             .py            all
com.sublimetext.3             .rb            all
com.sublimetext.3             .vbs           all
com.sublimetext.3             .tlc           all
com.sublimetext.3             .bat           all
com.sublimetext.3             .asm           all
com.sublimetext.3             .cgi           all
com.sublimetext.3             .rss           all
com.sublimetext.3             .xml           all
com.sublimetext.3             .atom          all
com.sublimetext.3             .csv           all
com.sublimetext.3             .bak           all
com.sublimetext.3             .cnf           all
com.sublimetext.3             .log           all
com.sublimetext.3             .asc           all
com.sublimetext.3             .diff          all
com.sublimetext.3             .temp          all
com.sublimetext.3             .tmp           all
com.sublimetext.3             .class         all
com.sublimetext.3             .yml           all

#  Video Player - VLC

org.videolan.vlc              .avi           Viewer
org.videolan.vlc              .mkv           Viewer
org.videolan.vlc              .wmv           Viewer
org.videolan.vlc              .mp4           Viewer
org.videolan.vlc              .m4v           Viewer
org.videolan.vlc              .mpeg          Viewer
org.videolan.vlc              .webm          Viewer
org.videolan.vlc              .mov           Viewer
org.videolan.vlc              .flv           Viewer
org.videolan.vlc              .f4v           Viewer
org.videolan.vlc              .vob           Viewer
org.videolan.vlc              .ogg           Viewer
org.videolan.vlc              .ogv           Viewer
org.videolan.vlc              .gifv          Viewer
org.videolan.vlc              .rm            Viewer
org.videolan.vlc              .asf           Viewer
org.videolan.vlc              .3gp           Viewer
org.videolan.vlc              .avchd         Viewer

# Image Editor - Photoshop

com.adobe.Photoshop           .jpg           all
com.adobe.Photoshop           .jpeg          all
com.adobe.Photoshop           .png           all
com.adobe.Photoshop           .bmp           all
com.adobe.Photoshop           .gif           all
com.adobe.Photoshop           .tif           all
com.adobe.Photoshop           .tiff          all

Executing duti

duti duti.conf

That's all! With a single command all these extensions where reassigned to a different app. Now we can change file association "the bulk way".

Checking Association

You can check what app is associated with the extensions too. For instance to check what app is associated with the md (markdown) extension:

duti -x .md

The output was:

MacDown.app
/Applications/Editors/MacDown.app
com.uranusjr.macdown

This is also useful to find apps' bundle ids. Just use Finder to change one extension manually to it (you can invent one), then check it's association with duti -x