0

I'm trying to write a little applescript that closes tabs that have URLs that do not contain certain text, but I can't get it to work.

Right now, my script closes every tab regardless of the URL. When it should only close specific URLs.

Can anyone tell me where I've gone wrong?

Here's the script…

tell windows of application "Google Chrome" to close (tabs whose URL does not contain {"business.facebook", "pinterest"} as text)
1
  • Note that you are coercing the list to a string, which is probably not what you want.
    – red_menace
    Jan 20, 2020 at 14:42

1 Answer 1

2

This works:

tell windows of application "Google Chrome"
    close (tabs whose URL does not contain "business.facebook" and URL does not contain "pinterest")
end tell

In an AppleScript whose clause you need to spell out each criteria fully and join them with a logical operator. You tried to use a list to make an implicit and; that makes sense to the human brain, but AppleScript can't parse it.

1
  • That works, thank you! And for the explanation too.
    – Mercuriel
    Jan 20, 2020 at 15:28

You must log in to answer this question.

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