« [Bash]OneDriveアップデート | トップページ | [TAG]タグの取得と管理方法ちょっと考え中 »

[NSURLContentTypeKey]NSURLの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

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

set strFilePath to "/System/Library/Fonts/Avenir Next.ttc"
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 listResult to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))

if (item 1 of listResult) is false then
return "取得に失敗しました"
else
  set ocidContentType to (item 2 of listResult)
  log className() of ocidContentType as text
  -->(*UTType*)
  set strUTI to (ocidContentType's identifier) as text
  -->"public.truetype-collection-font"
  log (ocidContentType's preferredFilenameExtension) as text
  --> ttc
end if


|

« [Bash]OneDriveアップデート | トップページ | [TAG]タグの取得と管理方法ちょっと考え中 »

UTType」カテゴリの記事