我是比较新的AppleScript的,我希望有人能帮助我解决这个...打开Finder别名
我有一个脚本,做一个聚光灯搜索,并返回找到的项目为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错误代码。我的猜测是,把original path
可以解决别名问题,但我不知道如何将它插入...谢谢了
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
不知道我是否正确地回答了您的问题,但如果您告诉Finder打开文件,它将始终由默认应用程序打开。这适用于文件,别名和文件夹。 – user309603 2014-09-11 07:06:41
这是我的假设,但正如我所说只有文件夹正确打开。别名返回错误。我的猜测是,我必须从别名中找出“原始”(当你点击别名上的获取信息时它会显示它)。我只是不知道如何处理 – user3101259 2014-09-11 19:24:33
您的问题令人困惑,因为“founditems”对我来说听起来是复数。例如,这不意味着1项。因为它是复数,我猜你实际上有一个项目清单。也许列表只包含1个项目,但它仍然是一个列表。如果我是正确的,那么当您尝试获取列表的“POSIX文件”时,这是没有意义的。这可能会导致你所有的麻烦。请展示如何使用Spotlight搜索生成Founditems,然后我们可以更好地帮助您。 – regulus6633 2014-09-11 19:59:08