Can you close safari windows based on Title? newb question sry

This is what I want to do-
I have a bunch of windows open that have the title “company A” and some that are “company B” etc. I would like a script that looks at the page title and closes all of the windows that are not “company A”

unfortunately because of a bad naming convention the url of the company sites is to similar to close them that way
This is what I tried but Title doesn’t compile I think I need to define it first
"if Title of front document does not contain “company A” then
close front window
Thanks for the help

Hi,

try this


tell application "Safari" to close (every window whose name is not "company A")

Thanks that worked