我在Automator工作流程中使用以下AppleScript:
on run {input, parameters}
--say input
set result_array to {} as list
try
repeat with this_file in input
tell application "Image Events"
launch
set this_image to open this_file
copy dimensions of this_image to {W, H}
close this_image
end tell
set text item delimiters to ":"
set file_name to last text item of (this_file as string)
set text item delimiters to ""
set filter_string to W & "x" & H as string
if file_name contains filter_string then
set the end of result_array to this_file
end if
end repeat
return result_array
on error error_message
display dialog error_message
end try
end run
脚本在Get Folder Contents
操作后运行。
结果数组有问题,但我无法弄清楚是什么。 结果必须是名称大小的文件列表。
答案 0 :(得分:2)
如果我理解正确,请使用以下其中一项:
if file_name contains filter_string then
-- set the end of result_array to this_file as alias
-- set the end of result_array to this_file as text
end if
目前this_file
就像是指向原始文件列表的指针。直接使用时,它包括当前值的索引和完整列表。
这可能是由于repeat with a in b
在Applescript中的实现方式。