Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a command line utility to which I can pass a filename, that will return applicable UTIs for that file?

For example:

hypothetical-uti-fetcher /Library/Desktop\ Pictures/Aqua\ Blue.jpg

might give me:

public.jpeg
public.image
public.data
share|improve this question

2 Answers 2

up vote 18 down vote accepted

You can use the mdls command to find the UTI for a file. Just do the command mdls /Library/Desktop\ Pictures/Aqua\ Blue.jpg and it will give you a bunch of info, toward the top it will say something like kMDItemContentType = "public.plain-text". Hope this helps!

share|improve this answer
1  
Excellent. Thanks. mdls -name kMDItemContentTypeTree /Library/Desktop\ Pictures/Aqua\ Blue.jpg is exactly what I wanted. –  smokris Nov 10 '10 at 0:41
    
You're welcome, I'm glad this helped. –  Wuffers Nov 10 '10 at 1:06
    
Suppose I turned off my Spotlight index and I seem to have no metadata stored. (mdls whatever-file just says that the file was not found). How do the md* services generate the content types in the first place? –  Aurel300 Feb 17 at 17:53

The mdls command only seems to work on Spotlight indexed files. If you run it on a mounted disk image, cd or thumb drive it may return no information at all. If the filetype's

http://uti.schwa.io/all has quite an extensive list of UTIs and is quite helpful. When you're developing a Quicklook Plugin it's also useful to use the following command to see what UTIs Quicklook thinks a file has and which plugins it uses for the preview:

qlmanage -d 4 -p /path/to/file
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.