« [UnInstall]パセリrcs300ドライバーアン・インストール | トップページ | [ResetLaunchPad]ランチパッドのリセット »

[UTType]拡張子からUTIを求める

#!/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 strFilePath to "/System/Library/Desktop Pictures/Solid Colors/Black.png" as text


################################

##パス関連

################################

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


log ocidUTI as text

-->(*public.png*)

log ocidUTType's preferredFilenameExtension() as text

-->(*png*)

log ocidUTType's tags as list

-->(*com.apple.ostype:PNGf, public.mime-type:image/png, com.apple.nspboard-type:Apple PNG pasteboard type, public.filename-extension:png*)

log ocidUTType's localizedDescription as text

-->(*PNGイメージ*)






#!/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 strFilePath to "/System/Library/Desktop Pictures/Solid Colors/Black.png" as text

################################
##パス関連
################################
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関連
################################
####UTIの取得
set listResponse to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
set ocidContentType to (item 2 of listResponse)
set ocidContentType to ocidContentType's identifier

log ocidContentType as text
-->(*public.png*)

|

« [UnInstall]パセリrcs300ドライバーアン・インストール | トップページ | [ResetLaunchPad]ランチパッドのリセット »

UTType」カテゴリの記事