LoginSignup
1
1

More than 5 years have passed since last update.

Mac にインストールされた同じバンドル ID のアプリケーションのフルパスを Terminal & AppleScript で取得する方法

Posted at

概要

友人に「Mac にインストールされた同じバンドル ID のアプリケーションのフルパスを AppleScipt で取得する方法」を聞かれていたのを思い出してググったら、Terminal でできることがわかったので、メモとして残しておく。

Terminal で取得する方法

Terminal を起動してコマンド入力。
サンプルでは Adobe Illustrator のバンドル ID である「com.adobe.illustrator」を指定している。

コマンド
$ mdfind "kMDItemCFBundleIdentifier == 'com.adobe.illustrator'"
結果
/Applications/Adobe Illustrator CC 2015.3/Adobe Illustrator.app
/Applications/Adobe Illustrator CC 2017/Adobe Illustrator.app

AppleScript で取得する方法

do shell script を使いましょう。

sample
tell application "Finder"
    set results to do shell script "mdfind \"kMDItemCFBundleIdentifier == 'com.adobe.illustrator'\""
    log results
end tell
結果
(*/Applications/Adobe Illustrator CC 2015.3/Adobe Illustrator.app
/Applications/Adobe Illustrator CC 2017/Adobe Illustrator.app*)

そもそもバンドル ID がわからないという方は

  1. Application フォルダを開いて、任意のアプリケーションを選択して、コンテキストメニューを表示
  2. 「パッケージの内容を表示」を選択
  3. Contents フォルダの中にある Info.plist をテキストエディタなどで開く
  4. CFBundleIdentifier を検索して、下の行にある文字列がバンドル ID なので、それを使う
<key>CFBundleIdentifier</key>
<string>com.adobe.illustrator</string>

参考

Searching multiple apps with same bundle ID

1
1
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
1
1