Xbox at E3 Square Enix at E3 E3's PC Gaming Show Next iPhone and LTPO displays Gmail adds collaboration tools Pre-Prime Day deals from Amazon

How to fix incorrect document associations in OS X

If opening documents in launches the wrong program, or if you are seeing repeated entries in OS X's Open With menu, then there is a quick solution.

Since a single type of document can often be opened by many different programs, OS X has a feature called Launch Services that centralizes document-handling associations.

When you add a program to the system, Launch Services will make it available as either the default handler of its associated document types (the program that will open documents of that type by default) or as an alternative handler. For instance, if you have Microsoft Word installed then it will be the default program for opening DOC files, but Apple's TextEdit program can also read DOC files, so TextEdit is available as an option if you right-click the document and choose "Open With." Additional programs will appear in this list if they are built to handle this document type.

However, sometimes errors can happen in Launch Services that prevent document associations from being reported correctly.

When this happens you may see documents being associated with the wrong program, manual changes to document associations not sticking, duplicate programs appearing in the Open With menu, or persistent error messages when opening documents that claim there is no application set to open the document.

If these problems happen, one approach is to clear Launch Services and reseed it with information from the programs you have installed. The utility for doing this is a command-line program called "lsregister" that is buried deep in the operating system. This is a bit unfortunate since it requires you to type the full (and lengthy) path to the program in order to execute it; however, you can work around this by executing a small find script to locate and run the program. To do this in the Terminal run the following command as is. Note that what looks like single quote marks in this command are actually grave accent marks (on the tilde key for English keyboard layouts) and not quotation marks:

sudo `find /System/Library/Frameworks -name lsregister` -kill -seed

This command will clear the current Launch Services configuration and then seed a new configuration with the information in program files that are in the default locations on the computer (such as the /Applications folder).

When this is finished, you should be able to open documents directly in their default handling programs, or at least be able to assign default handlers to programs without these settings reverting.

Do keep in mind that Launch Services is a dynamic database, which will grow as you install and use programs. If you do not see the program you want to use in the Open With menu for a document, then try opening that program separately. Simply opening the program should trigger a Launch Services entry for it, and make it available for future document associations. Keeping applications in nonstandard locations could contribute to problems in this area, so to ensure the system properly recognizes programs it is best to keep them in your Applications folder.

Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.