Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Liedenfrost

macrumors newbie
Original poster
Jul 27, 2010
5
0
Is there a way to close all but the active windows in Mac apps (I'm running 10.6.5). I often end up having 10 Safari screens open and it would be great to be able to close all but the current one I'm looking at.

Thanks.
 
Code:
tell app "safari"
	repeat while window 2 exists
		close window 2
	end repeat
end tell
 
Thanks for the code. When I run it, though, it doesn't automatically end; it just keeps looping and I have to manually quit it.
 
You could assign the Safari > Windows > Merge all Windows command via System Preferences > Keyboard > Keyboard Shortcuts to a keyboard shortcut and then use that assigned keyboard shortcut plus Command + Option + W to close all but the active tabs, then Command + W to close the active window.

merge.png
 
Thanks for the code. When I run it, though, it doesn't automatically end; it just keeps looping and I have to manually quit it.

You're right... that's weird. Works perfect in Finder.
[must be a Safari bug, as that syntax is pretty straightforward.]
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.