BundleIdentifier の Identifier ( 識別子文字列)を取り出す。
mac のアプリケーションの識別子こと kMDItemCFBundleIdentifier を調べる。
plutil でxml をgrep して CFBundleIdentifier を調べててたけど。もっと簡単に identifier を調べて、UTI文字列を取り出す方法を見つけたので、メモっておく。
takuya@.bin$ mdls -name kMDItemCFBundleIdentifier /Applications/Microsoft\ Remote\ Desktop.app kMDItemCFBundleIdentifier = "com.microsoft.rdc.mac"
mdls コマンドで Appの情報を取り出す
mdls /Applications/Google\ Chrome.app
アプリケーションのPATHを引数に与えてあげればいい。
mdls 自体は、 list の ls と meta data の md の意味らしい。 ( man mdls )
その他の使い方としては、mdlsを使えばファイルのメタデータを取得できるらしい。そのうち調べたい。
takuya@.bin$ mdls (null): no filename specified! usage: mdls [-name attr] [-raw [-nullMarker markerString]] [-plist file] path list the values of one or all the attributes of the specified file -raw: don't print attribute names before values -nullMarker: substitute this string for null attributes in raw mode -plist: output attributes in XML format to file. Use - to write to stdout option -plist is incompatible with options -raw, -nullMarker, and -name example: mdls ~/Pictures/Birthday.jpg example: mdls -name Keyword ~/Pictures/Birthday.jpg
コマンドの場所
コマンドは macOSにバンドルされていて、 /usr/bin/ に存在した。
takuya@.bin$ which mdls /usr/bin/mdls
mdls の取得例
takuya@.bin$ mdls /Applications/Microsoft\ Remote\ Desktop.app _kMDItemDisplayNameWithExtensions = "Microsoft Remote Desktop.app" _kTimeMachineNewestSnapshot = 4001-01-01 00:00:00 +0000 _kTimeMachineOldestSnapshot = 2018-08-12 03:51:06 +0000 kMDItemAlternateNames = ( "Microsoft Remote Desktop.app" ) kMDItemAppStoreCategory = "ビジネス" kMDItemAppStoreCategoryType = "public.app-category.business" kMDItemAppStoreIsAppleSigned = 1 kMDItemCFBundleIdentifier = "com.microsoft.rdc.mac" kMDItemContentCreationDate = 2017-01-12 00:21:41 +0000 kMDItemContentCreationDate_Ranking = 2017-01-12 00:00:00 +0000 kMDItemContentModificationDate = 2017-01-18 07:54:08 +0000 kMDItemContentType = "com.apple.application-bundle" kMDItemContentTypeTree = ( "com.apple.application-bundle", "com.apple.localizable-name-bundle", "com.apple.application-bundle", "public.directory", "public.executable", "com.apple.application", "public.item", "com.apple.package", "com.apple.bundle" ) kMDItemDateAdded = 2018-08-13 06:13:02 +0000 kMDItemDateAdded_Ranking = 2018-08-13 00:00:00 +0000 kMDItemDisplayName = "Microsoft Remote Desktop.app" kMDItemExecutableArchitectures = ( "x86_64" ) kMDItemFSContentChangeDate = 2017-01-18 07:54:08 +0000 kMDItemFSCreationDate = 2017-01-12 00:21:41 +0000 kMDItemFSCreatorCode = "" kMDItemFSFinderFlags = 0 kMDItemFSHasCustomIcon = (null) kMDItemFSInvisible = 0 kMDItemFSIsExtensionHidden = 1 kMDItemFSIsStationery = (null) kMDItemFSLabel = 0 kMDItemFSName = "Microsoft Remote Desktop.app" kMDItemFSNodeCount = 1 kMDItemFSOwnerGroupID = 0 kMDItemFSOwnerUserID = 0 kMDItemFSSize = 39006120 kMDItemFSTypeCode = "" kMDItemInterestingDate_Ranking = 2018-08-31 00:00:00 +0000 kMDItemKind = "アプリケーション" kMDItemLanguages = ( empty ) kMDItemLastUsedDate = 2018-08-31 03:58:51 +0000 kMDItemLastUsedDate_Ranking = 2018-08-31 00:00:00 +0000 kMDItemLogicalSize = 39006120 kMDItemPhysicalSize = 15273984 kMDItemUseCount = 4 kMDItemUsedDates = ( "2018-08-21 15:00:00 +0000", "2018-08-30 15:00:00 +0000" ) kMDItemVersion = "8.0.27246"