Apparently, UTI is the most reliable way to identify file types. I am wondering if UTI is exposed as a property by Finder, System Events or Standard Additions. If not, then does OS X Leopard offer a shell utility to reveal the UTI of a file?
Just found out that the type identifier property of class file under the Disk-file-folder suite of application System Events returns the UTI of the file.
Thanks, yuanqi! I know this was posted long ago but here’s a practical application of it…
-- Search by 'Uniform_Type_Identifier'
-- For more info goto https://en.wikipedia.org/wiki/Uniform_Type_Identifier
set samplfyl to (choose file with prompt "Select a sample file to get it's UTI.")
tell application "System Events"
set UTI to type identifier of samplfyl
set fylsWithSameUTI to (do shell script "mdfind kMDItemContentTypeTree == '" & UTI & "'")
return "Here is a list of UTI's matching '" & UTI & "':" & return & fylsWithSameUTI
end tell
Model: Mac Pro, Yosemite
AppleScript: 2.7
Browser: Safari 601.2.7
Operating System: macOS 10.14