How to Close Finder Tab?

Hey JM,

If I send you a script to run in a diagnostic context please do not add it to other scripts. I'm looking for a specific result without possible side-effects.

Okay, try running this before your close-tab menu action.

------------------------------------------------------------
set myDesktop to path to desktop
------------------------------------------------------------
tell application "System Events"
  if quit delay ≠ 0 then set quit delay to 0
  tell application process "Finder" to set frontmost to true
end tell
------------------------------------------------------------
tell application "Finder"
  if (insertion location as alias) = myDesktop then
    if (count of windows) > 0 then
      set index of window 1 to 1
    end if
  end if
end tell
------------------------------------------------------------

-Chris

1 Like