JuanPablo
JuanPablo

Reputation: 24834

applescript close tab in safari

with

tell application "Safari"
        set winlist to every window
        repeat with win in winlist
                set tablist to every tab in win
                repeat with t in tablist
                        name of t as string
                end repeat
        end repeat
end tell

I can get the name of safari tab

how I can close a tab with a specific name ?

Upvotes: 1

Views: 4509

Answers (3)

user1411444
user1411444

Reputation: 29

It doesn't work for me 2 Neither of them work The strange thing is, it does work when the safari is not in fullscreen I guess it is a bug in safari

Upvotes: 1

adayzdone
adayzdone

Reputation: 11238

Here is another approach:

tell application "Safari"
    set winlist to count of every window
    repeat with i from 1 to winlist
        close (every tab of window i whose name = "Google")
    end repeat
end tell

Upvotes: 3

Lri
Lri

Reputation: 27633

tell application "Safari"
    repeat with t in tabs of windows
        tell t
            if name starts with "autom" then close
        end tell
    end repeat
end tell

tell application "Safari" to close documents where name starts with "autom" would close all windows that contain tabs that start with autom.

Upvotes: 2

Related Questions