1

i want to issue a terminal command (invoking AppleScript is fine) to open a path in a Finder window in the current space.

if the path is open in Finder in another space, i don't want to switch to that space or move that finder window to the current space. if the path is already open in a Finder window in the current space, either focusing on it or opening a new Finder window to it would be fine.

i run a lot of spaces that are setup for different tasks, and i don't want to remove the Finder window from any other space i might be using it or switch to any other space.

nrser
  • 1,287
  • 1
  • 13
  • 23
  • What about just using the open command? For example "open /Applications" – TheDarkKnight Jun 03 '14 at 16:02
  • @Merlin069 that does not open a Finder window in the *current* space if one is open to that folder in another space. the question is specifically about opening a Finder window to the folder in the *current* space. – nrser Jun 04 '14 at 06:14
  • Sorry, I didn't notice you specified that a folder was open at the same location. – TheDarkKnight Jun 04 '14 at 07:28

1 Answers1

1

In Applescript, for example opening the Applications folder: -

tell application "Finder"
    make new Finder window to folder "Applications" of startup disk
end tell

You can save that as a script and call it from the command line with the osascript command, or you can execute it directly with the -e argument to osascript: -

osascript -e 'tell application "Finder" to make new Finder window to folder "Applications" of startup disk'

If you would like to open a specific path, instead of a named folder, you can reference the path with this:-

POSIX file "/some/directory/path"

So, a complete script would be: -

tell application "Finder"
    activate
    make new Finder window to (POSIX file "/some/directory/path")
end tell

Note: the activate command focuses the Finder window, which is optional.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • thanks for the response. i think i misspoke with regards to Finder terminology, what i wanted to do was open a *path*. question http://stackoverflow.com/questions/11261516/applescript-open-a-folder-in-finder helped me cobble together a working script. do you mind if i edit it in for others' reference? – nrser Jun 04 '14 at 09:39
  • Absolutely, if it makes an answer better, then go for it. – TheDarkKnight Jun 04 '14 at 10:10