Return (character position from string) or (file name from file path)
Here is what I am trying to do:
return a file name from a path:
myvolume:myfolder:myfile.txt
I want to return the file name.
Here is the handler I wrote to get the file name:
on getFileName(pathString)
set iCount to length of pathString
repeat while iCount > 1
if character iCount of pathString is ":" then
return (text (iCount + 1) thru (length of pathString)) of pathString as string
end if
set iCount to iCount - 1
end repeat
end getFileName
Is there an easier way to search a string?
Thank you.
g5 Dual 2ghz, Mac OS X (10.4.6), 2gb RAM