OSX将Shell脚本与文件扩展名相关联吗? [英] OSX Associate a shell script with a file extension?

查看:89
本文介绍了OSX将Shell脚本与文件扩展名相关联吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将.exe文件扩展名与启动wine的shell脚本相关联.做这个的最好方式是什么?

I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this?

从我收集的数据中,我需要创建一个将调用wine的AppleScript,但是如何在AppleScript中获取输入文件的名称呢?如果有更好的方法,请告诉我,但是据我所知,这是最好的方法.

From what I've gathered, I need to create an AppleScript that will call wine, but how do I get the name of the input file in the AppleScript? If there is a better way to do this, let me know, but as far as I know this is the best way.

推荐答案

您可以使用AppleScript应用程序执行此操作-例如,文件被传递到 open 处理程序,与小滴相同.:

You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example:

on open theFiles
    set arguments to ""
    repeat with anItem in theFiles
        set arguments to arguments & space & (quoted form of POSIX path of anItem)
    end repeat
    do shell script "/path/to/wine" & arguments
end open

要将特定的文档类型与您的应用程序相关联,您首先需要将信息添加到应用程序的信息属性列表( Info.plist )中,以告诉Launch Services它可以处理哪些类型的文档.参见Apple的基于文档的应用程序概述(或查看其他应用程序中的设置).

To associate a particular document type with your application, you will first need to add information to your application's information property list (Info.plist) to tell Launch Services what types of documents it can handle. See Apple's Document-Based Applications Overview (or take a look at the settings in other applications).

这篇关于OSX将Shell脚本与文件扩展名相关联吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆