Converting Unix path to AppleScript path
Converting Unix path to AppleScript path
- Subject: Converting Unix path to AppleScript path
- From: "Stockly, Ed" <email@hidden>
- Date: Mon, 27 Mar 2006 15:31:31 -0800
Hi,
I'm looking for a simpler and more reliable way to convert a UNIX style path (read from an XML file) to an appleScript style path (file "volume:directory:directory:file.ext" or alias "volume:directory:directory:file.ext")
In most cases the file is available on the network and is converted to an alias. In a few cases the volume is not available on the network, but the path is correct and the file reference should be returned.
When I first wrote this all I had to contend with was spaces in the file path, but it wasn't too long before there were pound signs (#).
(When I see # I'm thinking I've got at least 21 more characters to filter!).
I'm hoping there's a one line solution out there... anyone?
ES
(Here's what I'm doing now.
FixPhotoPath("file:///Volumes/Mag_Production/Color Lab Images/03:26/Issue #9 prepressed/tm.0326.chinaRS.tiff")
on FixPhotoPath(photoPath)
set myPath to POSIX path of photoPath
set photoPath to myPath as string
set AppleScript's text item delimiters to "#"
set photoPath to every text item of photoPath
set AppleScript's text item delimiters to "#"
set photoPath to photoPath as string
set AppleScript's text item delimiters to " "
set photoPath to every text item of photoPath
set photoPathEnd to the last item of photoPath
set AppleScript's text item delimiters to ">" & return
set photoPathEnd to every text item of (photoPathEnd & return)
set photoPathEnd to item 1 of photoPathEnd
set the last item of photoPath to paragraph 1 of photoPathEnd
set AppleScript's text item delimiters to " "
set photoPath to photoPath as string
set AppleScript's text item delimiters to ":Volumes:"
set photoPath to text item 2 of photoPath
try
set photoPath to photoPa!
th as alias
return photoPath
on error
return photoPath
end try
end FixPhotoPath
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden