Applescript 开放查找器别名

Applescript 开放查找器别名,applescript,Applescript,我对Applescript比较陌生,我希望有人能帮我解决这个问题 我有一个脚本,它执行聚光灯搜索,并将找到的项目返回为founditems。结果将是文件夹或文件夹的别名。我想打开找到的项目,如果结果是一个文件夹,它就会工作,但我不知道如何处理别名。使用别名,我将错误合并到代码中 try set theapp to default application of (get info for (POSIX file founditems)) as string tell applica

我对Applescript比较陌生,我希望有人能帮我解决这个问题

我有一个脚本,它执行聚光灯搜索,并将找到的项目返回为
founditems
。结果将是文件夹或文件夹的别名。我想打开找到的项目,如果结果是一个文件夹,它就会工作,但我不知道如何处理别名。使用别名,我将错误合并到代码中

try
    set theapp to default application of (get info for (POSIX file founditems)) as string
    tell application theapp to open (POSIX file founditems as string)
    activate application theapp
on error e
    display dialog "An error has occured trying to open your file:" & return & return & e buttons {"OK"} default button 1
end try
我得到10665错误码。我猜合并
原始路径
可能会解决别名问题,但我不确定如何插入它。。。多谢

founditems
是这样创建的:

set input_var to "12345"
set spotlightquery to "\"kMDItemFinderComment == '" & input_var & "'\""
set thefolders to {POSIX file "/Volumes/RAIDvolume"}


set founditems to {}
repeat with i in thefolders
    set thepath to quoted form of POSIX path of i
    if exists thepath then
        set command to "mdfind -onlyin " & thepath & " " & spotlightquery
        set founditems to founditems & (paragraphs of (do shell script command))
    end if
end repeat

这是一个列表,因为您使用了“的段落”,现在我可以看到founditems是一个posix路径列表。因此,无论路径是指向文件、文件夹还是别名,以下内容都将使用默认应用程序打开它

set founditems to {"/Users/hmcshane/Desktop/aaa alias"}
set macPath to POSIX file (item 1 of founditems)
tell application "Finder" to open macPath

我不确定你的问题是否正确,但如果你告诉查找程序打开文件,它将始终由默认应用程序打开。这适用于文件、别名和文件夹。这也是我的假设,但正如我所说,只有文件夹才能正确打开。别名返回错误。我的猜测是,我必须从别名中找出“原件”(当您点击获取别名信息时,它会显示出来)。我只是不知道该如何回答你的问题,因为“founditems”听起来是复数。例如,它不是founditem,这意味着1个项目。因为它是复数形式,我猜你实际上有一个项目列表。也许列表只包含一项,但它仍然是一个列表。如果我是对的,那么当您试图获取列表的“POSIX文件”时,它就没有意义了。这可能会给你带来所有的麻烦。请展示如何使用聚光灯搜索生成founditems,然后我们可以更好地帮助您……我注意到,
founditems
的代码实际上返回了一个列表,因此我尝试使用
founditems的第一项,但没有任何效果。。我编辑了我的问题,以包括确定
founditems
是什么的代码部分。也许这就是问题所在。谢谢雷格斯,看起来我们在同一时间想到了同样的事情!非常感谢你