Getting directory of input file (Applescript) -
i'm confused - i've been googling hour , have tried ten different forms of set posixdirectory posix path of (parent of (path afile) string)
can't seem right.
i'm getting full posix path (including filename) doing set posixfilepath posix path of afile
now, how posix path of directory?? i'm getting various errors depending on do... can't make alias.. can't parent of alias...
i think should work it's not... set posixdirectory posix path of ((parent of afile))
there couple of ways if have initial path.
from posix path format
set thepath "/users/username/documents/test/selectedtextcolour.css" set textnumber1 characters 1 thru -((offset of "/" in (reverse of items of thepath string)) + 1) of thepath string
or using shell
set thepath "/users/username/documents/test/selectedtextcolour.css" set parentpath shell script "dirname " & quoted form of thepath
result: "/users/username/documents/test"
from posix file format
set thepath "macintosh hd:users:username:documents:test:selectedtextcolour.css" set textnumber1 characters 1 thru -((offset of ":" in (reverse of items of thepath string)) + 1) of thepath string
result: "macintosh hd:users:username:documents:test"
Comments
Post a Comment