LoginSignup
5
4

More than 5 years have passed since last update.

サービスを使って特定のファイルを特定のアプリで開く

Last updated at Posted at 2015-01-07

サービスを使って特定のファイルを特定のアプリで開くためのスクリプトで、とりあえずバックアップ的なポスト。下記のコードは、PNGやJPEGなどをFireworksで開くようになってますが、拡張子やアプリを変更すれば、他のアプリでも使えると思います。

  1. Automatorで「新規作成」し、「サービス」を選択する。
  2. 右側のフローにある「受け取る項目」をファイルまたはフォルダに、「検索対象」をFinder.appに設定する。
  3. 左側のアクションライブラリからAppleScriptを実行を挿入し、下のコードをコピペして保存する。
  4. 「環境設定→キーボード→ショートカット」から「サービス」を選択し、先ほど作成したサービスにショートカットを設定する。
on run {input, parameters}

    set fileList to {}

    tell application "Finder"
        activate

        set selectionFiles to selection
        repeat with selectionFile in selectionFiles
            set fileExt to name extension of selectionFile
            if fileExt = "jpg" or fileExt = "jpeg" or fileExt = "png" or fileExt = "gif" or fileExt = "psd" or fileExt = "ai" then
                set end of fileList to selectionFile
            end if
        end repeat

        open fileList using application file (alias "Macintosh HD:Applications:Adobe Fireworks CS6:Adobe Fireworks CS6.app:")

    end tell

    return input
end run

ちなみにFireworks CS6以外を使っている場合やApplicationsフォルダ以外にインストールしている場合は、パスを変更してください。

OSX10.9までは動作してました。あと、例外処理はあまり考えてないので、えぇ。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4