Hello. Maybe you can use this on posixPathOfAnytingAsText(anyFileOrFolderPath) -- returns the full posix pathname of anything if the files exists local tids, theFile, lastItem, tidsToUse, singleQuoteCheck -- Thanks to Yvan Koenig :) set singleQuoteCheck to false set tidsToUse to ":" try (get class of anyFileOrFolderPath) on error number -1728 -- it was a filereference set anyFileOrFolderPath to POSIX path of (anyFileOrFolderPath as alias) as text return anyFileOrFolderPath end try
set anyFileOrFolderPath to "" & anyFileOrFolderPath -- doesn't harm. if anyFileOrFolderPath starts with "'" and anyFileOrFolderPath ends with "'" then set anyFileOrFolderPath to text 2 thru -2 of anyFileOrFolderPath set singleQuoteCheck to true end if if anyFileOrFolderPath starts with "/" and singleQuteCheck is false then return anyFileOrFolderPath else if anyFileOrFolderPath starts with "/" or anyFileOrFolderPath starts with "~" then set tidsToUse to "/" end if
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tidsToUse} set anyFileOrFolderPath to text items of anyFileOrFolderPath as text if singleQuoteCheck is true then set AppleScript's text item delimiters to "'\\''" set anyFileOrFolderPath to text items of anyFileOrFolderPath -- as list set AppleScript's text item delimiters to "'" end if set anyFileOrFolderPath to "" & anyFileOrFolderPath set AppleScript's text item delimiters to tidsToUse
if tidsToUse is ":" then -- the first item isn' like disk nr 1 then we have to do something. if text item 1 of anyFileOrFolderPath is not item 1 of (list disks) then set anyFileOrFolderPath to {"Volumes"} & text items of anyFileOrFolderPath else set anyFileOrFolderPath to {""} & text items 2 thru -1 of anyFileOrFolderPath end if set AppleScript's text item delimiters to "/" else if text item 1 of anyFileOrFolderPath is "~" then -- mus get the posix path as text set anyFileOrFolderPath to text items 2 thru -2 of (POSIX path of (path to home folder) as text) & text items 2 thru -1 of anyFileOrFolderPath end if set anyFileOrFolderPath to "" & anyFileOrFolderPath set AppleScript's text item delimiters to tids return anyFileOrFolderPath end posixPathOfAnytingAsText |