Where does Mac OS X store file association information?

24

19

I know there is a system preferences pane to manually modify the file associations in Mac OS X Leopard. However, I'm curious where does Leopard actually store these information?

I'm not interested in methods to change them. I want to know the configuration file or database (like registry in Windows) where those mappings are stored.

Mehrdad Afshari

Posted 2009-08-10T20:52:33.517

Reputation: 3 031

some please re-tag this with "mac" and "osx" (those tags are more widely used) – Thilo – 2009-08-11T00:57:20.853

There was a discussion on meta on this but I couldn't conclude which tag wins. – Mehrdad Afshari – 2009-08-11T10:22:22.443

I suppose the best way to decide the winner is to look at the numbers. Popularity beats taxonomy on social network sites. – Thilo – 2009-08-13T01:13:33.220

See also: http://superuser.com/questions/17761/file-association-for-editing-on-a-mac (slightly different, but may also be helpful).

– Jonathan Leffler – 2009-09-16T04:58:56.603

Answers

12

Sorry, this question is old, but the answer is really wrong.

As toolbear mentioned, Doug Harris' answer is only partially correct.

The Launch Services Database file, which is where all of the information for all known applications and the types of documents they can handle is stored, is located in the following location:

Lion:

/private/var/folders/**/**/-Caches-/com.apple.LaunchServices-034501.csstore

Snow Leopard:

/private/var/folders/**/**/-Caches-/com.apple.LaunchServices-025501.csstore

Leopard:

/Library/Caches/com.apple.LaunchServices-023501.csstore

The /private/var/folders/ folder is where the "secure" Caches and Temporary folders for each user are stored. The **'s in the path shown above will be something like /dl/dlXWtS5WH9SNboPxxrDIyE+++TI/, or another obscure character sequence to prevent guessing.

Note that the name com.apple.LaunchServices-025501.csstore is composed of the user ID (mine is 501) appended to the -025 suffix, which is unique to Snow Leopard. (In each version of OS X, Apple tends to change the distinguishing suffix used to prevent compatibility problems between different versions of OS X. You'll notice that Leopard used -023). Lion is using the -034 suffix.

NSGod

Posted 2009-08-10T20:52:33.517

Reputation: 1 485

2El Capitan 10.11.4: $TMPDIR/../0/com.apple.LaunchServices-134$(id -u).csstore – rob mayoff – 2016-05-12T14:49:20.437

But those are temporary folders. Those can't be where it is centrally stored. – Melab – 2016-09-11T00:35:33.553

1

@Melab: Each application on a Mac system has an Info.plist file (https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigFiles.html) which describes its capabilities. Launch Services gathers all of that information dynamically to create the database mentioned above. If the database file were removed Launch Services (specifically the lsregister tool -- http://ss64.com/osx/lsregister.html) can recreate it.

– NSGod – 2016-09-12T13:36:46.127

Actually, just from the path, it looks like it's stored alongside the temporary folders (.. means "go up a level"). – SilverWolf - Reinstate Monica – 2017-10-02T16:50:48.250

18

OS X uses a "defaults" system -- here's a nice article with lots of examples. The files are stored under ~/Library/Preferences, but it's best to manipulate with the "defaults" command rather than editing the plists directly.

File associations are stored under the com.apple.LaunchServices domain. From the link above, you can see the list with this command:

defaults read com.apple.LaunchServices | grep -v LSBundleLocator

Far more information about Launch Services specifically, can be found in Apple's Launch Services Programming Guide

Doug Harris

Posted 2009-08-10T20:52:33.517

Reputation: 23 578

15

@Doug Harris' answer is only partially correct. The defaults system stores your local additions or overrides to the file associations. However, OS X comes with some default, system wide associations.

If you run lsregister -dump you'll see what Launch Services calls CoreTypes and the associations provided by applications it finds.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -dump

I haven't exhaustively scanned the output. There may be others sources indicated in that dump, but a large number of these types come from /System/Library/CoreServices/CoreTypes.bundle. There may be a plaintext or plist file in there where the types are enumerated. The associations I believe come from scanning the contents of *.app in known application locations. Here's where Launch Services understands TextWrangler is an editor to numerous file types:

--------------------------------------------------------------------------------
bundle  id:            10928
    path:          /Applications/TextWrangler.app
    name:          TextWrangler
    identifier:    com.barebones.textwrangler (0x8000008d)
    ...
    library items:
    --------------------------------------------------------
    claim   id:            20216
        name:          TextWrangler text document
        rank:          Default
        roles:         Editor  
        flags:         relative-icon-path  
        icon:          Contents/Resources/TextWranglerTextDoc.icns
        bindings:      .a, .asm, .asp, .bashrc, .c, .c++, .cc, .cfm, .conf, .cp, .cpp, .cshrc, .css, .cxx, .equ, .f, .f77, .for, .ftn, .h, .h++, .hpp, .htm, .html, .inc, .j, .java, .js, .jsp, .log, .m, .mm, .p, .pas, .pch, .pch++, .php, .php3, .pl, .plist, .plx, .pm, .ppu, .r, .rb, .rez, .rhtml, .rss, .s, .sql, .shtm, .shtml, .tcl, .tcshrc, .text, .txt, .wml, .xhtml, .xml, .xsl, .xslt, .yaml, 'TEXT'
    ...

toolbear74

Posted 2009-08-10T20:52:33.517

Reputation: 340

2@SlippD.Thompson look carefully at the next line, the path is specified there. – Dmitry Ginzburg – 2014-09-16T11:50:33.410

1FYI -bash: lsregister: command not found in Mavericks – Slipp D. Thompson – 2014-02-05T02:55:08.077

2

Easy peasy! Its just that it isn't in the most obvious place:

  • Right click on the file you want to change the association for and select "Get Info" (or just select and hit Command+I.
  • Go down to "Opens With" (you may need to click the arrow next to it to expand it) and select another program from the drop down box.
  • Click the "Change All..." button to change this file association for all files of the same extension on your system.

enter image description here

You could also go out and install RCDefaultApp prefpane to modify all file associations in one place.

Josh Hunt

Posted 2009-08-10T20:52:33.517

Reputation: 20 095

3Did you read the question? It was about where OS X stores the information, not how to change the associations. – Jonik – 2009-08-11T10:28:23.803

1Yeah, but knowing how to change them also helps. Like it helped for me... @joshhunt: maybe if you made it explicit that the Get Info stuff is in the Finder with the file selected. (Just had to undo one application grabbing another's files - this helped.) – Jonathan Leffler – 2009-09-17T19:16:58.047

@LauriRanta you're absolutely right, in fact after I posted that, I wanted to delete it, but I couldn't find it! – ocodo – 2012-10-24T02:52:33.403

-3

~/Library/Preferences/com.apple.LaunchServices.plist

Nate

Posted 2009-08-10T20:52:33.517

Reputation: 4 013