How do you duplicate current open Finder view in new tab (Mavericks)?
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?
You can do it by pressing:
cmd+ctrl+O
on any folder and it'll show up in a new tab.
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.
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