Now that we have this great ability to send AppleScript commands to the terminal, I find that it is a royal pain to convert the Finder path to a Unix style path. This is especially true when you have multiple volumes. This script has the "unix_path" subroutine that takes a Mac path and converts it to a UNIX path while taking into account just about every weird character you can throw at it.
As an example, it will display the Mac and UNIX path of the current Finder item, then open a terminal window and give a file-listing of the current finder-item.
Read the rest of the article for the Mac to UNIX path conversion script -- you'll have to enter this into ScriptEditor and save it in order to use it, of course.
on run
tell application "Finder"
set this_item to the selection as alias
end tell
display dialog of (this_item as text)
set mypath to posix_path(this_item)
display dialog of mypath
set the clipboard to mypath
end run
on posix_path(mac_path)
set mac_path to (mac_path as text)
set root to (offset of ":" in mac_path)
set rootdisk to (characters 1 thru (root - 1) of mac_path)
tell application "Finder"
if (disk (rootdisk as string) is the startup disk) then
set unixpath to "/" & (characters (root + 1) thru end of mac_path)
else
set unixpath to "/Volumes:" & mac_path
end if
end tell
set chars to every character of unixpath
repeat with i from 2 to length of chars
if item i of chars as text is equal to "/" then
set item i of chars to ":"
else if item i of chars as text is equal to ":" then
set item i of chars to "/"
else if item i of chars as text is equal to "'" then
set item i of chars to "\\'"
else if item i of chars as text is equal to "\"" then
set item i of chars to "\\" & "\""
else if item i of chars as text is equal to "*" then
set item i of chars to "\\*"
else if item i of chars as text is equal to "?" then
set item i of chars to "\\?"
else if item i of chars as text is equal to " " then
set item i of chars to "\\ "
else if item i of chars as text is equal to "\\" then
set item i of chars to "\\\\"
end if
end repeat
return every item of chars as string
end posix_path
Mac OS X Hints
http://hints.macworld.com/article.php?story=20011030193449870