October 9th, 2007, 12:19 PM #1
HFS path in Terminal?
Hi - I would like to use the 'open -a finder' command in the terminal with a HFS path - is that possible?
open -a finder "Macintosh HD:Users"
October 9th, 2007, 01:25 PM #2
As far as I know, there's no simple way to do that. There are some complicated ways, though.
I often need to convert paths from one type to another with AppleScript, where it's fairly easy:
return POSIX path of file "Macintosh HD:Users" --returns "/Users"
...and the reverse...
return posix file "/Users" --returns file "Macintosh HD:Users"
You can embed AppleScripts in terminal commands by using the "osascript" command (the reverse is also true with AppleScript's "do shell script" command). What's more, you can pass the result of one terminal command as a parameter for another by encasing it in ` characters. That means that this method can be applied directly in Terminal.
Depending on why and how you need to do this, it might be unforgivably inelegant, but you be the judge. Anyway, here's the final command:
open -a finder `osascript -e 'return POSIX path of file "Macintosh HD:Users"'`
That's probably not the only way to do it, but I'm sure any other way would use a similar technique.
October 9th, 2007, 01:51 PM #3
That is just what I was Looking for!!!
Thank you OSX Master!!!