I have a set of bookmarks in a folder. Usually, I open them by selecting the folder and then "Open in New Tabs". Is it possible to do this using a script? I imagine AppleScript would be the right tool here, but anything that is included with the system would work as an answer.

1 Answer 1


If you are just wanting to script the clicking go the Open in New Tabs menu item of the target folder under Bookmarks, then the following example AppleScript code will do that:

set bookmarksFolder to "Saved Tabs"

tell application "Safari" to activate

delay 1

tell application "System Events" to ¬
    click menu item "Open in New Tabs" of ¬
        menu 1 of ¬
        menu item bookmarksFolder of ¬
        menu 1 of ¬
        menu bar item "Bookmarks" of ¬
        menu bar 1 of ¬
        application process "Safari"

Just change "Saved Tabs" in the first line of code to the actual name of the target folder on the Bookmarks menu.

Here is something a bit more robust…

I have different sets of URLs that I group into different windows by themselves, and have made an AppleScript application from the code. You can use the example AppleScript code below to do the same:

set myURLs to {¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬
    "https://somedomain.com", ¬

tell application "Safari"
    make new document with properties {URL:first item of myURLs}
    tell window 1
        set bounds to {0, 22, 1136, 844}
        delay 1
        repeat with i from 2 to count myURLs
            set current tab to (make new tab with properties {URL:item i of myURLs})
            delay 2
        end repeat
        set current tab to fourth tab
    end tell
end tell

Obviously "https://somedomain.com" is just a place holder for the real URL. The set bounds … and set current tab … commands can be adjusted to your liking or omitted.

I called the AppleScript application My Regular Sites, gave it a nice icon through the Get Info window method, and put it in the Dock.

This make it real easy to open Safari with a window containing my regular sites.

Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

  • Thanks, @user3439894, this is exactly what I was looking for. One thing that tripped me up trying to use your first script is that my folder was in the "Favorites" folder (as a subfolder). So it's just a matter of putting it as a top-level folder in the bookmarks.
    – Carlos
    May 29, 2020 at 21:13
  • 1
    @Carlos, If you want to leave it in the Favorites folder, just add of menu 1 of menu item "Favorites" ¬ after: menu item bookmarksFolder of ¬ May 29, 2020 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .