Revolution filepath to Applescript file: how to?
Joel Guillod
joel.guillod at net2000.ch
Tue Aug 2 03:20:33 EDT 2005
I am looking for a script to convert a filepath to an Applescript
file statement. For example:
"/Users/toto/Desktop/Image 6.png" => file "Image 6.png" in the
folder "Desktop" in home
My current version is as below but it does not deal with files
outside the /Users directory. Who can help me?
function Applescript_filepathFor pFile
set the itemdel to "/"
if offset($HOME,pFile) is 1 then
if there is a file pFile then put "file" && q(last item of
pFile) into r
else put "folder" && q(last item of pFile) into r
delete char 1 to len($HOME) of pFile
repeat with i=the num of items in pFile -1 down to 2 -- 2
because first item is empty ("/...").
put " in the folder" && q(item i of pFile) after r
end repeat
return r && "in home"
else throw "ERROR: I DONT KNOW HOW TO CONVERT:" && PARAMS()
end Applescript_filepathFor
Thanks, jg
More information about the use-livecode
mailing list