Applescript 中列表项的属性列表

List of properties of list items in Applescript

我正在获取 applescript 中的文件列表,如下所示:

set _resourcesFolder to folder (((path to me) as string) & "Contents:Resources:")
set _signatureFiles to files of _resourcesFolder whose name extension is in {"html", "webarchive"}

然后我想在单独的列表中获取这些项目的属性。试了一下:

set _signatureNames to displayed name of _signatureFiles
set _signatureDate to modification date of _signatureFiles

这行不通。但这确实:

set _signatureNames to displayed name of files of _resourcesFolder whose name extension is in {"html", "webarchive"}
set _signatureDate to modification date of files of _resourcesFolder whose name extension is in {"html", "webarchive"}

为什么会这样?

在您的第一个片段中,您定义了两个列表:_resourcesFolder_signatureFiles

在您的第二个代码段中,您的代码要求获取其中一个列表的显示名称和修改日期。这失败了,因为您正在处理列表,而不是列表中的项目。

在您的第三个代码段中,您正确地分别处理了各个项目,一切都很好。

唯一可用的其他方法(基于您的原始代码段)是重复 _signatureFiles 中的文件并创建列表或记录作为重复的一部分。第三个片段中的代码是在单个命令中执行此操作的唯一方法。