AppleScript to open a collection of Safari tabs

Apr 18, '11 07:30:01AM

Contributed by: Dana Nau

Here's a simple AppleScript that replaces the current Safari window with a collection of tabs, each open to a different URL. I've seen several scripts that attempt to do something similar, but this one improves on them in a couple of ways:

The URLs in the script are just an example; obviously you'll want to replace them with others.
tell application "Safari"
  activate
  -- close all but one tab of the front window
  try
    repeat
      close tab 2 of window 1
    end repeat
  end try
  -- open the URLs in separate tabs
  tell window 1
    set URL of tab 1 to "http://weather.yahoo.com/forecast/USMD0100.html"
    make new tab with properties {URL:"http://www.weather.com/weather/today/College+Park+MD+20740"}
    make new tab with properties {URL:"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=20742"}
    make new tab with properties {URL:"http://www.accuweather.com/us/md/college-park/20742/city-weather-forecast.asp"}
    make new tab with properties {URL:"http://weather.weatherbug.com/MD/College%20Park-weather.html?zcode=z6286&zip=20742"}
  end tell
end tell

[crarko adds: I tested this, and it works as described.]

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110415065236737