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?

6 Answers 6

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.

6
  • Works exactly as I wanted! Thank you. I compiled the script as an app and put its icon on the Finder toolbar, so I always have it handy on every Finder window.
    – magoo
    Oct 31, 2013 at 10:15
  • @magoo: you could create a service with automator that runs this apple script and then assign a keyboard shortcut through SystemPreferences->Keyboard->Shortcuts->AppShortcuts.
    – DudeOnRock
    Dec 16, 2013 at 1:42
  • Before using keystroke, it's better to do set frontmost to true first, make sure that keystroke is execute on Finder not something else.
    – Albert
    Jun 15, 2015 at 6:30
  • 10 years later, but @magoo you should mark this answer as the accepted answer, since it helped you accomplish what it is you set out to do. Jul 17, 2023 at 12:07
  • @EzekielVictor: thanks for the reminder. Just did it (10 years later 😉)
    – magoo
    Aug 9, 2023 at 16:35
19

You can do it by pressing:

cmd+ctrl+O

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

2
  • 3
    This will open a selected folder in a new tab. However, this only works if the "Finder Preferences > Open folders in tabs instead of new windows" option is checked. Otherwise, it will open the selected folder in a new window instead of in a new tab. Again, this works based on the selected folder - not the currently open location of a tab/window. And it won't work at all with no folder selected. So technically, this doesn't answer the posted question.
    – MikMak
    Jun 8, 2019 at 22:25
  • This is amazing, thank you...
    – Tallboy
    Jun 1, 2020 at 22:49
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...

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
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.

1
  • 3
    This is just wrong. Delete this. Apr 7, 2017 at 3:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .