My script needs to open a Finder window with a particular file selected. There is an AppleScript command exactly for this purpose: reveal.
set theFile to POSIX file "..."
tell application "Finder"
activate
reveal theFile
end tell
The problem is that there is no way to say “be dumb and just create a new window.” No, the command is always smart-alecky and invariably reuses an existing Finder window if one is already displaying the folder of the file to be revealed (called the target in Finder dictionary terms). For scripts, this behavior creates two unwelcome side effects:
- How do you distinguish a newly created window from a reused one? I want to close the new window but leave the reused one alone.
- Worse, if the current Space has no window to reuse but another Space does, Finder will happily reuse the window in that other Space — and that breaks everything. Programmatically, Apple treats Spaces as separate universes, and scripting across Spaces is not something I’m eager to do or recommend.
The solution seems straightforward: just open a new Finder window and set its target in advance to the folder of the file to be revealed:
-- innocent-looking
set theFile to POSIX file "..."
set theFileFolder to POSIX file "..."
tell application "Finder"
activate
make new Finder window
set target of the result to theFileFolder
reveal theFile
end tell
But it does not work. The new window is created, it shows the correct folder — yet reveal completely ignores it as a target candidate, as if it doesn’t exist.
And this is not an AppleScript issue. The “Show in Enclosing Folder” command in Finder and the “Reveal” action in the Shortcuts app behave exactly the same way. Somehow the window is not kosher enough for revealing.
Long story short, there appears to be a bug somewhere inside the implementation of the target property that corrupts something in the Finder window’s internal metadata if you pass an alias directly.
The fix:
-- somewhat enigmatic fix
set theFile to POSIX file "..."
set theFileFolder to POSIX file "..."
tell application "Finder"
activate
make new Finder window
set the target of the result to (get folder theFileFolder)
reveal theFile
end tell
By the way, the following variant doesn’t work. The entire
set the target of the result to folder theFileFolder
statement is compiled into a single Apple event under the hood, and the problematic alias is buried inside it as a parameter. In contrast, the explicit get command in the working version forces AppleScript to generate two separate Apple events.
-- not a fix
set theFile to POSIX file "..."
set theFileFolder to POSIX file "..."
tell application "Finder"
activate
make new Finder window
set the target of the result to folder theFileFolder
reveal theFile
end tell
If you want your source code to look less enigmatic, you can introduce explicit variables:
-- less of enigma
set theFile to POSIX file "..."
set theFileFolder to POSIX file "..."
tell application "Finder"
activate
set theWindow to make new Finder window
set theTarget to folder theFileFolder
set target of theWindow to theTarget
reveal theFile
end tell

