Is there anything more convenient than using RCDefaultApp or Magic Launch, or just repeatedly pressing the Change All buttons in Finder's information panels?

I thought about writing a shell script that would modify the CFBundleDocumentTypes arrays in Info.plist files. But each app has multiple keys (sometimes an icon) that would need to be changed.

lsregister can't be used to make specific modifications to the Launch Services database.

$ `locate lsregister` -h
lsregister: [OPTIONS] [ <path>... ]
                      [ -apps <domain>[,domain]... ]
                      [ -libs <domain>[,domain]... ]
                      [ -all  <domain>[,domain]... ]

Paths are searched for applications to register with the Launch Service database.
Valid domains are "system", "local", "network" and "user". Domains can also
be specified using only the first letter.

  -kill     Reset the Launch Services database before doing anything else
  -seed     If database isn't seeded, scan default locations for applications and libraries to register
  -lint     Print information about plist errors while registering bundles
  -convert  Register apps found in older LS database files
  -lazy n   Sleep for n seconds before registering/scanning
  -r        Recursive directory scan, do not recurse into packages or invisible directories
  -R        Recursive directory scan, descending into packages and invisible directories
  -f        force-update registration even if mod date is unchanged
  -u        unregister instead of register
  -v        Display progress information
  -dump     Display full database contents after registration
  -h        Display this help
  • Awesome work Lauri, the net is awash with people suggesting Cmd-i, Change All. I'll give duti a whirl next time I try out another App that re-registers dozens of file types. – ocodo Jul 3 '12 at 2:44


  1. Download the pkg installer or compile from source
  2. Save a file like this somewhere:

    com.macromates.textmate public.shell-script all
    com.macromates.textmate public.unix-executable all
    com.macromates.textmate com.apple.property-list all
    org.videolan.vlc .avi all
    org.videolan.vlc .mkv all
    # ...
  3. duti $file.duti

Finding bundle identifiers or UTIs:

bundleid() {
  osascript -e "id of app \"$*\""

getuti() {
  local f="/tmp/me.lri.getuti.${1##*.}"
  touch "$f"
  mdimport "$f"
  mdls -name kMDItemContentTypeTree "$f"
  rm "$f"


I wrote a Ruby script a lot like duti before I found out about it. It requires restarting the OS to apply the changes though. It also overwrites any external changes to com.apple.LaunchServices.plist.

#!/usr/bin/env ruby

datafile = "#{ENV['HOME']}/Notes/lsapps.txt"
cachedir = "#{ENV['HOME']}/Library/Caches/me.lri.scripts"
cachefile = cachedir + "/lsapps"
`mkdir -p #{cachedir}; touch #{cachefile}`
cachetext = IO.read(cachefile)

a = []
IO.readlines(datafile).each do |line|
  next unless line =~ /^([^#].*): (.+)/
  z = $1, $2

  bid = cachetext.scan(/#{z[0]}  (.*)/)[0]
  unless bid
    bid = `osascript -e 'id of app "#{z[0]}"'`.chomp
    next unless bid
    File.open(cachefile, "a") { |f| f.puts(z[0] + "  " + bid) }

  z[1].strip.split(" ").each do |e|
    if e =~ /(.+):\/\/$/
      a << "{LSHandlerURLScheme='#{$1}';LSHandlerRoleAll='#{bid}';}"
    elsif e.include?(".")
      a << "{LSHandlerContentType='#{e}';LSHandlerRoleAll='#{bid}';}"
      a << "{LSHandlerContentTag='#{e}';LSHandlerContentTagClass=\

system("defaults", "write", "com.apple.LaunchServices", "LSHandlers",
"(" + a.join(",") + ")")

`defaults write com.apple.LaunchServices LSQuarantine -bool false`


NetNewsWire Lite: feed:// public.rss
iCal: icaltodo icalevent
Google Chrome: chrome://
Safari: public.html
TextEdit: txt text md markdown csv
TextMate: public.shell-script public.unix-executable public.script ssh:// xml plist dict css rst tex sh pl py rb gemspec php js java c h m conf bash opml as cfm cfml class coffee ctp erb rhtml haml less msass scss yaml rd
VLC: avi mpg flv mkv mp4 flac 3gp
The Unarchiver: rar
Skim: pdf
iChm: chm
AppleScript Editor: scpt
Sequential: png jpg

You can change what application opens all AVIs quite easily, no scripting required. Find an AVI file, and do Get Info on it. This will show you the file information. Select the program you want to open the files, then click the "Change All..." button. That will prompt you to change the default association. enter image description here

Just as a small point, resource forks aren't being phased out, but creator codes are. As such, newer Mac OS systems have a more flexible system for working out how to open files. Applications are supposed to work on files that don't have resource forks, but some applications still use them.

  • 1
    Changing the default app from an information dialog requires about 10 mouse or keyboard actions. That gets pretty annoying after the first few hundred times or so. – Lri Sep 29 '11 at 23:03
  • In that case, see this answer elsewhere on the site, it'll show you how to do a command line batch change. – mauvedeity Oct 8 '11 at 8:44
  • (The linked answer is about about changing the default app of a single file from its resource fork.) Even if I modified the resource forks of all of my existing files, it wouldn't change the default apps of files I will have in the future. – Lri Oct 8 '11 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.