Close All Other Documents in BBEdit’s Window

A simple AppleScript to close all other documents (ie: everything except for the document you’re currently editing) in the front-most BBEdit window:

try
    tell application "BBEdit"
        set mywindow to window 1
        set mydoc to (URL of document 1 of mywindow) as POSIX file

        set alldocs to documents of mywindow
        repeat with doc in alldocs
            if ((((URL of doc) as POSIX file) as string) is equal to (mydoc as string)) then
                -- active doc
            else
                close doc
            end if
        end repeat
    end tell
on error
    beep
end try

Copy, paste, & save it as a file in ~/Library/Application Support/BBEdit/Scripts, where you’ll be able to invoke it via BBEdit’s Scripts palette (Window → Palettes → Scripts) or via the Scripts menu (whose visibility can be toggled on or off in the Preferences window’s Menus & Shortcuts pane).