Duplicate a Tab in the Current Finder Window

I just installed Monterey on my Mac Min M1: no particular problem.
But, impossible to find a trick to duplicate a tab in the current Finder window!...
I still propose this simple procedure, based on a KM macro in two steps:
1 - AppleScript: tell application "Finder" to make new Finder window to (get Finder window 1's target)
2 - Finder menu “Merge all windows”
I hope this will help you, but if you have faster and less complex (with for example a simple and unique AppleScript), I'm interested... :wink:

Something like this?

tell application "Finder"
	set theTarget to target of window 1
	tell application "System Events"
		keystroke "t" using command down
	end tell
	set target of window 1 to theTarget
end tell

Unfortunately there's still no "tab" in the Finder's AppleScript dictionary -- tabs are just windows sharing the same GUI wrapper, it seems.

Doesn’t typing T do anything for you? Here on Mojave it creates a new tab in Finder.

Yes, it works, but it always opens the same tab corresponding to a Finder preference "New Finder windows show" when I want to open the same tab, same folder.

1 Like

Really much more elegant solution than mine. Thank you... :wink:

That AppleScript did not work on my 2020 MacBook Pro with macOS 12.4: The new tab was created, but its path was never changed.

Apparently, creating the new tab is just a tiny bit too slow on my Mac, so that the set target of window 1 to theTarget statement got executed a little bit before the new tab was ready to receive the original path. And when I say tiny bit too slow, I really do mean tiny: A delay 0.01 before that statement is apparently sufficiently long to fix the script on my machine (delay 0.001 was not long enough).

To err on the side of caution, I'm now using a 0.3s delay. The full version of the modified script is therefore:

tell application "Finder"
	set theTarget to target of window 1
	tell application "System Events"
		keystroke "t" using command down
	end tell
	delay 0.3
	set target of window 1 to theTarget
end tell

Thank you very much for the original script, @Nige_S! I had originally created a KM macro that saved %FinderInsertionLocation% to a variable and then pasted that variable into the Go -> Go to Folder… window in Finder. That macro works, too, but it's a bit slower than your AppleScript and having the Go to Folder dialog briefly pop up is a bit distracting.