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

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to