Closing all but the active windows of an app

Discussion in 'macOS' started by Liedenfrost, Nov 20, 2010.

  1. Liedenfrost macrumors newbie

    Joined:
    Jul 27, 2010
    #1
    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.
     
  2. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
  3. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #3
    Code:
    tell app "safari"
    	repeat while window 2 exists
    		close window 2
    	end repeat
    end tell
    
     
  4. Liedenfrost thread starter macrumors newbie

    Joined:
    Jul 27, 2010
    #4
    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.
     
  5. spinnerlys Guest

    spinnerlys

    Joined:
    Sep 7, 2008
    Location:
    forlod bygningen
    #5
    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
     
  6. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #6
    You're right... that's weird. Works perfect in Finder.
    [must be a Safari bug, as that syntax is pretty straightforward.]
     

Share This Page