Need macro to close all instances of an active app except the current one

I do a lot of research in PDF files using Skim . So, I end up having about 10-20 open heavy PDF files at a time and this tends to slow down my mac.
Is there any macro or shortcut that I can use to close all the instances of an app excluding the active one?

Hey Mirizzi,

With KM you could get a list of windows, bring them to the front, and close them one by one.

But this is more efficiently done with AppleScript.

------------------------------------------
# Close all but front document.
------------------------------------------
tell application "Skim"
  set docList to documents
  if length of docList > 1 then
    repeat with i from 1 to length of docList
      if i > 1 then
        close (item i of docList)
      end if
    end repeat
  end if
end tell
------------------------------------------

-Chris

2 Likes

Works perfectly. Thanks.