[CFBundleDocumentTypes]アプリケーションの対応DocumentTypesを取得する
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application
property strBundleID : "com.apple.QuickTimePlayerX"
set listUTI to doGetUTI()
log listUTI
to doGetUTI()
###アプリケーションのURLを取得
###NSバンドルをUTIから取得
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
if ocidAppBundle = (missing value) then
###NSバンドル取得できなかった場合
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppPathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
else
set ocidAppPathURL to ocidAppBundle's bundleURL()
end if
###Plistのパス
set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
if ocidDocTypeArray = (missing value) then
set strOutPutText to "missing value" as text
else
####リストにする
set listUTl to {} as list
###対応ドキュメントタイプをリストにしていく
repeat with itemDocTypeArray in ocidDocTypeArray
set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
if listContentTypes = (missing value) then
###拡張子の指定のみの場合
set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
set strClassName to ocidExtension's className() as text
repeat with itemExtension in ocidExtension
set strExtension to itemExtension as text
set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
set strContentTypes to ocidContentTypes's identifier() as text
set strContentTypes to ("" & strContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
else
repeat with itemContentTypes in listContentTypes
set strContentTypes to ("" & itemContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
end if
end repeat
end if
return listUTl
end doGetUTI
| 固定リンク
「UTType」カテゴリの記事
- シンボリックリンクのUTIの取得(2024.12.02)
- [UTType]処理対象のUTI(ファイルタイプ)か?チェックする 複数UTIでチェックする(2024.10.03)
- [UTType]処理対象のUTI(ファイルタイプ)か?チェックする(2024.09.30)
- UTI(uniform type identifier)の取得 ツリー構造付き 少し修正(2024.06.19)
- UTI(uniform type identifier)の取得 ツリー構造付き(2024.05.23)