11

In a thread on this forum there is an interesting solution on how to open a duplicate of an already open Finder window with the help of an AppleScript: How do you duplicate current open Finder view?

With the new tabbed Finder in OS X 10.9 Mavericks, I am wondering if there is a way to implement an AppleScript that opens the duplicate in a new Finder tab instead of a new Finder window? Did anybody succeed in finding a solution?

magoo
  • 113
  • 1
  • 1
  • 6

6 Answers6

19

You can do it by pressing:

cmd+ctrl+O

on any folder and it'll show up in a new tab.

Meseery
  • 299
7

Finder's dictionary doesn't have support for tabs, but you can simulate pressing command-T:

tell application "Finder"
    activate
    set t to target of Finder window 1
    set toolbar visible of window 1 to true
end tell
tell application "System Events"
    keystroke "t" using command down
end tell
tell application "Finder"
    set target of Finder window 1 to t
end tell

The target of a Finder window is the folder shown on the title bar, which does not depend on what items are selected in list view.

Lri
  • 42,502
  • 8
  • 126
  • 159
3

On previous versions of MacOS (Before Monterey) - Cmd + Ctrl + O - worked perfectly...you could even Cmd + double click on a folder in the Finder path bar to open a new window at that location. Or if you enabled Finder>Preferences>General "Open folders in tabs instead of new windows", Cmd + double click on a path bar folder would open that location in a new tab.

However, after Monterey it seems those options no longer work. You can still (tediously) right-click the folder and pick "Open in New Window" or "Open in New Tab", but the shortcut of Cmd + Ctrl + O or Cmd + double click no longer works (even though you can see it in the menu options).

This MacRumors forum is the ONLY place I could find discussing this revelation: https://forums.macrumors.com/threads/cmd-double-click-on-finder-path-bar-doesnt-open-folder-in-new-window.2331090/


Versions tested: Monterey 12.5.1 (on Intel), 12.1 (on Apple Silicon), Big Sur 11.6.2, Catalina 10.15.7...

DarkDiamond
  • 1,919
  • 11
  • 15
  • 21
ZANI.dev
  • 31
  • 2
1

I wrote a script for this today, pretty similar to how @Lri has done it.

https://gist.github.com/n8henrie/0ceef75964bd153f910d

-- duplicateFinderTab.scpt
-- Uses a hacky workaroud to duplicate the frontmost Finder tab,
-- since Apple hasn't provided great AppleScript support for this.

on new_tab()
    tell application "System Events" to tell application process "Finder"
        set frontmost to true
        tell front menu bar to tell menu "File" to tell menu item "New Tab"
            perform action "AXPress"
        end tell
    end tell
end new_tab

on run {}
    tell application "Finder"
        if (count of Finder windows) > 0 then set duplicate_me to target of front Finder window
    end tell

    -- Short delay may or may not be necessary, mine seems to work without.
    -- delay 0.2

    new_tab()
    tell application "Finder"
        set target of front Finder window to duplicate_me
    end tell
end run
n8henrie
  • 325
  • 3
  • 11
1

This is @n8henrie's solution, except with a tweak to reselect the selected items, which I kind of like:

-- duplicateFinderTab.scpt
-- Uses a hacky workaroud to duplicate the frontmost Finder tab,
-- since Apple hasn't provided great AppleScript support for this.

----------------------------------------------
on run {}
    tell application "Finder"
        if (count of Finder windows) > 0 then set duplicate_me to target of front Finder window
        set _sel to the selection
    end tell

    -- Short delay may or may not be necessary, mine seems to work without.
    -- delay 0.2

    new_tab()

    tell application "Finder"
        set target of front Finder window to duplicate_me
        select _sel
    end tell
end run

----------------------------------------------
on new_tab()
    tell application "System Events" to tell application process "Finder"
        set frontmost to true
        tell front menu bar to tell menu "File" to tell menu item "New Tab"
            perform action "AXPress"
        end tell
    end tell
end new_tab
-2

Click the finder tab you want to duplicate, then CMD+T.

Jens Erat
  • 18,485
  • 14
  • 68
  • 80
GNOK
  • 1