How to associate URL files with a specific browser in Snow Leopard

finderurl

Until Snow Leopard URL files (.webloc files that you get when you drag a URL onto the desktop) opened with OmniWeb on my computer and some URLs were configured to open with Safari.

After upgrading to Snow Leopard all URL files open with "Finder" which then proceeds to open the standard browser (OmniWeb) for them. I tried changing the association, but Snow Leopard insists that these files be opened with OmniWeb via Finder.

Any ideas what I can do to fix this? I want all webloc files to open in OmniWeb except for specific ones which should open in Safari. I had it configured that way but at some point Mac OS X decided that the Safari ones should open with Finder (which then opens them with OmniWeb) and it just ignores it when I try to change that configuration per file

Best Answer

As far as I know, there is no way to associate .webloc files with a specific application. Your best bet would probably be to use some AppleScript.
I made a little script that lets you generate tiny little AppleScript applications that open in the browser that you select upon creation (OmniWeb, Safari, or Chrome).

You can download the script here, or compile it yourself from the code below.

set theURL to text returned of (display dialog "What URL would you like to bookmark?" with title "Enter URL" default answer "http://")
set theApp to (choose from list {"OmniWeb", "Safari", "Chrome"} with prompt "Which application would you like to associate with the bookmark?" with title "Select Application") as string
set theName to text returned of (display dialog "What would you like to name the bookmark?" with title "Enter Name" default answer "")
set theFolder to choose folder with prompt "Where would you like to save the bookmark?"

if theApp is "OmniWeb" then
    set theScript to "tell application \"OmniWeb\"
    activate
    try
        set theTab to make new tab at end of front browser with properties {address:\"" & theURL & "\"}
        set active tab of front browser to theTab
    on error
        make new browser with properties {address:\"" & theURL & "\"}
    end try
end tell"
else if theApp is "Safari" then
    set theScript to "tell application \"Safari\"
    activate
    try
        set theTab to make new tab at end of tabs of front window
        set the URL of theTab to \"" & theURL & "\"
    on error
        make new document
        set theTab to tab 1 of front window
        set the URL of theTab to \"" & theURL & "\"
    end try
    set current tab of front window to theTab
end tell"
else if theApp is "Chrome" then
    set theScript to "tell application \"Google Chrome\"
    activate
    if (count of windows) = 0 then
        make new window
        set URL of tab 0 of front window to \"" & theURL & "\"
    else
        set URL of (make new tab at end of tabs of front window) to \"" & theURL & "\"
    end if
end tell"
end if

tell application "AppleScript Editor"
    set theDoc to make new document with data theScript
    save theDoc as "application" in ((theFolder as string) & theName & ".app")
end tell

Running that will prompt you for the URL, the browser you want it to open with, and the location to save the 'bookmark'.

You can put this in your Applications or Scripts folder for easy access and invoke it whenever you want to save a URL.