AppleScript名:Vanilla Scriptで指定ファイルのUTIを求める |
set aFile to choose file
tell application "System Events" set aUTI to type identifier of aFile return aUTI end tell |
AppleScript名:指定ファイルのUTIを取得 |
— Created 2016-10-24 by Takaaki Naganoya — Modified 2016-10-25 by Shane Stanley — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use BridgePlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html set aFile to POSIX path of (choose file) set aUTI to retFileFormatUTIFromPath(aFile) of me on retFileFormatUTIFromPath(aPOSIXpath as string) load framework set aPath to current application’s NSString’s stringWithString:aPOSIXpath set aExt to (aPath’s pathExtension()) as string return (current application’s SMSForder’s UTIForExtension:aExt) as list of string or string –as anything end retFileFormatUTIFromPath |
AppleScript名:指定ファイルのUTIを取得 v2.scptd |
use AppleScript version "2.5" — El Capitan (10.11) or later use framework "Foundation" use scripting additions property |NSURL| : a reference to current application’s |NSURL| property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey set aPath to POSIX path of (choose file) set utiRes to retUTIfromPath(aPath) of me on retUTIfromPath(aPOSIXPath) set aURL to |NSURL|’s fileURLWithPath:aPOSIXPath set {theResult, theValue} to aURL’s getResourceValue:(reference) forKey:NSURLTypeIdentifierKey |error|:(missing value) if theResult = true then return theValue as string else return theResult end if end retUTIfromPath |