I have been using the AppleScript below as an Automator service in order to get Safari to close all tabs to the right of the current tab. However I have updated to Mavericks (10.9) and find that this no longer works.

Can anyone advise how this AppleScript should be changed in order to make it work again?

Here's the script:

    tell application "Safari"
  set indexActive to index of current tab of window 1
    repeat until (get index of last tab of window 1) = indexActive
        close last tab of window 1
    end repeat
end tell
  • Can you put the code in the question and not on an external site
    – mmmmmm
    Oct 26, 2013 at 11:41

1 Answer 1


Your script still worked in my limited testing, but you could also try something like this:

tell window 1 of application "Safari"
    close (tabs where index > (get index of current tab))
  • Weird. It started working again once I did a restart. And Thanks for the concise alternative script!
    – Macrod
    Oct 26, 2013 at 13:32

You must log in to answer this question.

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