[Basic]MimeTypeとUTI
#!/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 scripting additions
use framework "UniformTypeIdentifiers"
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
property objUTType : a reference to objMe's UTType
####ダイアログで使うデフォルトロケーション
tell application "Finder"
set aliasDefaultLocation to container of (path to me) as alias
##set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
####MIMEリスト
set listMimeType to {"image/jpeg", "image/png", "image/webp", "image/heic", "image/bmp"}
####UTIリスト
set listUTI to {"public.jpeg", "public.png", "public.webp", "public.heic", "public.bmp"}
####ダイアログを出す
set aliasFilePath to (choose file with prompt "ファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
####ファイルのインフォメーションを取得
set objInfoFor to info for aliasFilePath
tell objInfoFor
###UTIを取得
set strTypeIdentifier to type identifier as text
###拡張子を取得
set strExtension to name extension as text
end tell
####拡張子からUTI取得
set ocidUTType to objUTType's typeWithFilenameExtension:strExtension
set strUTI to ocidUTType's identifier as text
####UTIからMIME取得
set ocidFileMimeType to ocidUTType's preferredMIMEType()
set strFileMimeType to ocidFileMimeType as text
####MIMEリストを順番に
repeat with objMimeType in listMimeType
set strMimeType to objMimeType as text
####リストの項目と照合
if strFileMimeType is strMimeType then
log strMimeType & "である"
else
log strMimeType & "これではない"
end if
end repeat
| 固定リンク
「Basic」カテゴリの記事
- [appleScript through]文字列から指定範囲の文字列を取り出す(2024.12.28)
- [置換]ラインセパレーター(lines separates) の置換(2024.12.27)
- [concatenation] &で連結(2024.12.21)
- [基本]through(2024.10.27)
- ファイルの上書きチェックとファイル名変更(2024.01.18)
「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)