[UTI] UTTypタグの一覧を取得する
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set objFileManager to refMe's NSFileManager's defaultManager()
###デスクトップ
set ocidUserDesktopPath to (objFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set aliasDefaultLocation to ocidUserDesktopPath as alias
set listChooseFileUTI to {"public.item"}
set strPromptText to "ファイルを選んでください" as text
set aliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listChooseFileUTI with invisibles and showing package contents without multiple selections allowed) as alias
-->alias
################################
##パス関連
################################
set strFilePath to POSIX path of aliasFilePath
set ocidFilePathStr to (refMe's NSString's stringWithString:strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
set ocidExtensionName to ocidFilePathURL's pathExtension()
################################
##UTI関連
################################
set ocidUTType to (refMe's UTType's typeWithFilenameExtension:ocidExtensionName)
set ocidUTI to ocidUTType's identifier
###UTI
log ocidUTI as text
###拡張子
log ocidUTType's preferredFilenameExtension() as text
###メタタグ一覧
log ocidUTType's tags as record
####Mine
log ((ocidUTType's tags)'s valueForKey:"public.mime-type") as text
##############################
set ocidTagsDict to (ocidUTType's tags)
set ocidUTTypeTagsKeys to ocidTagsDict's allKeys()
set strOutPut to "UTI:" & (ocidUTI as text) & "\n" as text
repeat with itemTagsKeys in ocidUTTypeTagsKeys
set ocidValue to (ocidTagsDict's valueForKey:itemTagsKeys)
set strOutPut to strOutPut & (itemTagsKeys as text) & ":" & (ocidValue as text) & "\n"
end repeat
display dialog "Uniform Type Identifier\rMimeType" default answer strOutPut with icon note
| 固定リンク
「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)