duti

From RaySoft

duti is a command-line utility capable of setting default applications for various document types on macOS, using Apple's Uniform Type Identifiers (UTI).[1]

Documentation

Syntax

duti [-d UTI] [-l UTI] [FILE]
duti -s BUNDLE-ID UTI|URL-SCHEME [ROLE]
duti -x EXTENSION

Parameters

-d UTI
Display the default handler for a Uniform Type Identifier (UTI).
-l UTI
Display all handlers for a Uniform Type Identifier (UTI).
-s
Set the handler from data provided on the command line.
-x EXTENSION
Print information describing the default application for file EXTENSION.

Examples

Set the default handler for a file extension
duti -s 'org.videolan.vlc' '.mp4' 'all'
Print the default application for a given file extension
duti -x '.mp4'

Output:

VLC.app
/Applications/VLC.app
org.videolan.vlc
Get the default handler for a UTI
duti -d 'public.mpeg-4'

Output:

org.videolan.vlc
Get all handlers for a UTI
duti -l 'public.mpeg-4'

Output:

com.apple.QuickTimePlayerX
com.apple.system-library
org.videolan.vlc
Get the handler ID using AppleScript
osascript -e 'id of app "VLC"'

Output:

org.videolan.vlc

References