Can someone tell me what can be done with the uti of a file. Here I used TextEdit and Tex-Edit Plus rtf files:
set f_list to choose file with multiple selections allowed
set uti_list to {}
repeat with this_f in f_list
tell application "System Events"
set end of uti_list to type identifier of this_f
end tell
end repeat
uti_list
--> {"public.rtf", "com.apple.traditional-mac-plain-text"}
-- "TextEdit" and "Tex-Edit Plus"
Think I have one use for getting the uti. If you’re making an app and you want the app to be able to open that file, then you add the uti to the plist. Is there anything else you can do?
Edited: I guess you could also find out if an application can open that file.
On my side, I use type identifiers in this kind of instruction :
choose file of type{"public.plain-text"} # TextEdit text documents
choose file of type{ "public.rtf", "public.rtfd"}
choose file of type{"com.apple.iwork.pages.pages"}
choose file of type{"com.apple.iwork.numbers.numbers","com.apple.iWork.Numbers.sffnumbers","com.apple.iWork.Numbers.numbers-tef"}
choose file of type{"com.adobe.pdf"}
Yvan KOENIG (VALLAURIS, France) dimanche 28 septembre 2014 22:07:55
I just thought of something. Someone could identify files from a certain application using ‘of type’ in the ‘choose file’ command especially if the type identifier is unique or rare.
much, much, much, much . much faster using Spotlight
set inputFolder to POSIX path of (choose folder)
set some_type_id to "public.rtf"
paragraphs of (do shell script "mdfind -onlyin " & quoted form of inputFolder & " 'kMDItemContentType = \"" & some_type_id & "\"'")
PS: entire contents in System Events has a different meaning as in Finder
Yes that is much better. In fact, I cannot use Finder’s ‘entire contents’ with System Event’s ‘type identifier’ without merging the tell blocs somehow. And, I don’t like that anyway if it could be done. The script is quick!
I have never seen the kMDItemContentType. Is that part of the mdfind? I need to look at the man page still.