How to prevent applications on an external hard drive from showing up in the "Open With" contextual menu?

15

7

I have two hard drives on my machine (Lion). One contains the regular copy of OS that I use everyday, the one has a slightly older copy of the OS that I keep as a backup (in case the first drive stops working).

A somewhat annoying problem is that whenever I right-click on a file and go to "Open With", two entries for each application I have will show up in the cascading menu, one from each copy of an application from the two drives. The one from the everyday-use-drive will have a newer version because I update them regularly (This way I can tell which app to use).

I looked around the documentation and it seems like I can use Launch Services

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister

but I haven't found any example that does exactly what I am looking for. Any ideas? Thanks!

ceiling cat

Posted 2011-10-21T02:10:18.110

Reputation: 3 557

Unmount the other partition? – Daniel Beck – 2011-10-21T12:28:55.107

I don't want to do that because I have some other files (that I actively use) in the same drive. – ceiling cat – 2011-10-21T17:34:06.073

Answers

18

Try this procedure:

  1. Exclude your second drive from Spotlight indexing (or, if you want to keep access to it via Spotlight, just exclude its /Applications folder) by dragging its icon into the Privacy pane of the Spotlight System Settings. This will preclude Launch Services from seeing the apps on the drive and re-registering them in the next step.
  2. Make Launch Services reload the list of available apps with the command /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -all local,system,user. As apps on the second drive are not available via Spotlight anymore, the new database will only contain those on your main drive.
  3. Restart Finder to rebuild its Open With context menu (Option-right click on its Dock icon to get the restart option, or do killall Finder in Terminal).

kopischke

Posted 2011-10-21T02:10:18.110

Reputation: 2 056

I can't believe how long I just dealt with this before looking this up. Thank you! Dealing with OSX when a drive with an old OS install is attached is infinitely less annoying now. – squarecandy – 2017-05-12T23:20:56.283

My app containers are distributed across numerous folders on my external drive, though mainly in a Downloads folder when not in the Applications folder. Would be nice to control this some other way, i.e. include/exlude list of locations etc. – gone – 2019-02-13T04:06:05.363

awesome! Worked perfectly. – ceiling cat – 2011-10-21T17:33:06.217

but then "find" (files and folders) feature won't work on that external drive :( – Nimbuz – 2012-08-01T07:20:13.217

@Nimbuz: that is so if you exclude the whole drive, as the find feature is Spotlight. However, as I pointed out in the answer, you can keep finding anything but apps by only excluding /Applications on the external drive. – kopischke – 2012-08-02T08:03:35.340

There is no option to disable indexing for external drive only. You just enable or disable it. – Nimbuz – 2012-08-03T07:55:41.640

2@Nimbuz: You can add individual folders to Spotlight’s privacy pane from any drive – external or internal. Just follow the instructions in the answer. – kopischke – 2012-08-03T09:11:28.567