MacOS – AppleScript: How to create a new Finder window for a folder that is already open


The problem, outside of AppleScript:

To witness the problem1, do the following:

  • Double-click on a folder that exists on the Desktop. Doing so will open this folder in

  • Return to the Desktop and double-click on that same folder again.

  • Instead of a second window being created, the previously created window will be brought to the foreground.

A workaround, outside of AppleScript:

So, what do you do if you want two Finder windows of the same folder?

A kluge exists:

Create a new Finder window by opening any other folder. From within this new window, now if you navigate to the desired folder, then you will successfully change this window to the desired folder, and have two windows of this folder.

To navigate to the desired folder within a new Finder window, any method will work:

  • Click on the folder, if it is bookmarked in the sidebar (if enabled, located at the left of the window).

  • Click on the folder, if it happens to exist in the path bar (if enabled, located at the bottom of the window).

  • Use the window's built-in search bar.

  • Or, simply navigate to the folder manually.

The problem, in AppleScript:

The following AppleScript code will open a folder in a new Finder window:

set targetFolder to POSIX file "/Users/Me/Desktop/MyFolder"

tell application "Finder"
    open targetFolder
end tell

In the exact same way that Finder behaves non-programatically (as defined above), if you run this code for a second time (without closing the previously created Finder window), then the previously created window will be brought to the foreground.

The desired AppleScript solution:

Here is the desired behavior:

  • If targetFolder already exists in any open Finder window (including any minimized Finder window), I would like the AppleScript to create a new window for the same targetFolder (i.e., a duplicate window).

Ideally, I would like the duplicate window to be created, without having to resort to the "trick" that I delineated above (i.e., opening an arbitrary other folder first, before opening the desired folder). However, I will understand if this is not possible (i.e., if the programmatic method must replicate the manual method).

1. I understand that this behavior is in no way a bug or a "real" problem. Apple clearly programmed this action deliberately; they probably determined that most people do not need or want redundant Finder windows.

OS X El Capitan, version 10.11.6.

Best Answer

Simple way to make a New Finder Window to the Desktop.

set myTarget to ((path to desktop) as text)

tell application "Finder" to make new Finder window to folder myTarget