无法通过Applescript获取列表中文件夹的项目
我没有通过此代码获取图像文件夹内的文件。如何在给定变量(文件列表)中获取该文件的名称?
set p to "/Users/sumeet/Desktop/images/"
set a to POSIX file p
set filelist to (names of items of (POSIX file a))
-- file "Macintosh HD:usr:local:bin:"
I am not getting the file inside the images folder through this code. How can I get that file's name in the given variable (filelist)?
set p to "/Users/sumeet/Desktop/images/"
set a to POSIX file p
set filelist to (names of items of (POSIX file a))
-- file "Macintosh HD:usr:local:bin:"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将起作用:
您必须告诉 Finder 来获取项目列表。此外,Finder 只接受
alias
路径,因此您必须将 unix 路径更改为别名 (aaa:aaa:aaa:) 格式。你也可以这样做:
This will work :
You have to tell Finder to get the list of items. Also Finder only takes
alias
paths, so you have to change the unix path to an alias (aaa:aaa:aaa:) format.You could also do it this way :
你犯了一些错误。首先,您尝试获取
file
对象 (a
) 的POSIX 文件
。您只使用一次。其次,当您实际指的是项目名称
时,您使用了项目名称
。您的方式在语法上更有意义,但 Applescript 不正确。第三,您必须要求 Finder 为您执行此操作,因为您想要查看文件系统。You had a few mistakes. First, you tried to take the
POSIX file
of afile
object (a
). You only use this once. Second, you usednames of items
when you actually meantname of items
. Your way makes more sense grammatically, but is incorrect Applescript. Third, you have to ask Finder to do this for you, since you want to look at the file system.