【发布时间】:2014-05-02 11:06:27
【问题描述】:
我在编写脚本时遇到了一些麻烦(我认为这会是)我正在处理的一个非常简单的部分。基本上,我想告诉 Finder 使用特定应用程序打开文件。很简单,对吧?根据我的阅读,我应该可以使用:
tell application "Finder"
open "the_file" using "the_application"
end tell
问题在于 Finder 似乎很难找到应用程序。当我使用以下代码时:
set webArcExtract to POSIX file (do shell script "mdfind 'WebArchive Folderizer.app' -onlyin '/Applications/'") as string #Find the Web Archive Extraction Program
tell application "Finder" #Temporary path to save the web archive
set tempPath to ((home as string) & "temp:")
end tell
tell application "Fake" #Magic that saves a webpage as a webarchive
load URL "www.google.com"
delay 3
capture web page as Web Archive saving in tempPath & "arc.webarchive"
end tell
tell application "Finder" #Open the arc.webarchive file saved in the tempPath with the WebArchive Folderizer application
open tempPath & "arc.webarchive" using webArcExtract
end tell
变量的值如下:
tempPath: "OSX_Data:Users:user:" webArcExtract: "OSX:Applications:Utilities:WebArchive Folderizer.app"
我在尝试运行代码时遇到的错误发生在 open tempPath & "arc.webarchive" using webArcExtract 行上。 Finder 会弹出一条消息,指出“找不到应用程序”。
我真的被这个弄糊涂了。我知道路径是正确的,我知道应用程序可以通过这种方式打开文件。我可以使用 Finder 转到我尝试打开的 arc.webarchive 文件,右键单击该文件,然后选择“使用 > WebArchive 文件夹打开”,它可以完美运行。
有什么建议吗?
【问题讨论】:
标签: applescript using finder tell