我很困惑 - 我已经在谷歌上搜索了一个小时,并且尝试了大约十种不同的形式set posixDirectory to POSIX path of (parent of (path to aFile) as string)
但我似乎无法做对。
我通过执行以下操作获取完整的 POSIX 路径(包括文件名)set posixFilePath to POSIX path of aFile
现在,我如何获取目录的 POSIX 路径?根据我所做的事情,我收到各种错误...无法创建别名..无法获取别名的父级...
我认为这应该有效,但事实并非如此......set posixDirectory to POSIX path of ((parent of aFile))
如果您已经有了初始路径,有几种方法可以做到这一点。
来自 Posix 路径格式
set thePath to "/Users/USERNAME/Documents/Test/selectedTextColour.css"
set textNumber1 to characters 1 thru -((offset of "/" in (reverse of items of thePath as string)) + 1) of thePath as string
或使用外壳
set thePath to "/Users/USERNAME/Documents/Test/selectedTextColour.css"
set parentPath to do shell script "dirname " & quoted form of thePath
Result: "/Users/USERNAME/Documents/Test"
来自 Posix 文件格式
set thePath to "Macintosh HD:Users:USERNAME:Documents:Test:selectedTextColour.css"
set textNumber1 to characters 1 thru -((offset of ":" in (reverse of items of thePath as string)) + 1) of thePath as string
Result: "Macintosh HD:Users:USERNAME:Documents:Test"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)