I work a lot between the OS X command line and Finder and AS, so I’ve written functions to convert between Finder (“:” delimited) and UNIX (“/” delimited) paths. In addition these functions handle paths to non-startup drives, which via the command line must be accessed through /Volumes. Also, you can convert folder paths, not just file paths. Feel free to use it, copy it, and modify it. They’re not complicated, and actually use different methods. I take no responsibility for any harm that may come form using them.
on MactoUNIX(docFolder)
set docFolderString to docFolder as string
set docFolderString2 to "/"
set startupDisk to ""
tell application "Finder"
set startupDisk to name of startup disk
end tell
set diskNameLength to length of startupDisk
set tempStr to (characters 1 thru (diskNameLength + 1) of docFolderString) as string
if tempStr contains startupDisk then
set docFolderString2 to "/"
else
set docFolderString2 to "/Volumes/"
end if
set counter to 1
repeat while counter is less than ((length of docFolderString) + 1)
set currChar to character counter of docFolderString
if currChar is ":" then
set docFolderString2 to docFolderString2 & "/"
else
set docFolderString2 to docFolderString2 & currChar
end if
set counter to counter + 1
end repeat
return docFolderString2
end MactoUNIX
on UNIXtoMac(UNIXString)
set temp1 to 0
set macString to ""
set UStart to (characters 1 thru 8 of UNIXString) as string
if (UStart contains "Volumes") then
set UNIXString to (characters 10 thru (length of UNIXString) of UNIXString) as string
else
set UNIXString to characters 2 thru (length of UNIXString) as string
end if
repeat while (length of UNIXString) is greater than 0
set temp1 to offset of "/" in UNIXString
if temp1 is 1 then
set macString to macString & ":"
else
set macString to (macString & (characters 1 thru (temp1 - 1) of UNIXString) as string)
end if
if temp1 is not 0 then
set macString to macString & ":"
if temp1 is less than (length of UNIXString) then
set UNIXString to (characters (temp1 + 1) thru length of UNIXString) as string
else
set UNIXString to ""
end if
else
set UNIXString to ""
end if
end repeat
return macString
end UNIXtoMac