[英]Opening a file with an app using a command line in apple script or an automator app
我希望能够双击以在特定应用程序(SeaMonkey composer)中打开文件类型(HTML)。
双击该文件将打开SeaMonkey Browser,但是我希望它在Seamonkey Composer中打开。 唯一的方法是使用以下命令行
seamonkey -editor "filename.html"
因此,如何使用Apple脚本或自动程序在composer中打开html文件?
如果要使用AppleScript进行此操作,则此简单脚本应该可以完成此任务:
set filePath to ((path to documents folder) as text) & "filename.html"
tell application "Seamonkey Composer" to open filePath
我没有要测试的Seamonkey Composer应用程序,但它可与BBEdit一起使用。 请注意, open
命令必须具有文件的完整路径。
将以下脚本另存为“脚本编辑器”中的“应用程序”:
on run filesList
repeat with fileRef in filesList
do shell script "seamonkey -editor " & quoted form of POSIX path of fileRef
end repeat
end run
选择“查看”>“显示捆绑包内容”,然后为其指定自定义的捆绑包ID。 然后,您可以如上所述更改文件关联。
以上假设seamonkey
命令本身只是一个启动器; 如果它实际上是完整的应用程序(可能是这种情况,因为它显然不是本地Mac应用程序),则中间行需要进行一些调整:
do shell script "nohup seamonkey -editor " & quoted form of POSIX path of fileRef & " >/dev/null 2>&1"
那应该允许shell脚本在启动seamonkey
进程后立即退出,从而使Seamonkey一直运行,直到您从其GUI退出为止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.