HFS path in Terminal?

ravenwaver

Registered
Hi - I would like to use the 'open -a finder' command in the terminal with a HFS path - is that possible?

ie:
open -a finder "Macintosh HD:Users"

Thanks

Paul
 
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.
 
Back
Top