![]() |
Using mdfind questions
In another thread, Hayne used mdfind with an attribute equality to find all applications on a volume. Specifically, he used:
mdfind 'kMDItemContentTypeTree == \"com.apple.application\"c' Having spent some time exploring mdfind, I'm left with some questions. Why use mdfind 'kMDItemContentTypeTree == "com.apple.application"c' as opposed to 'kMDItemkind == "Application"', and what is the follow-on "c" doing? The content type of an application seems to be "com.apple.application-bundle" for those I've looked at. Was the objective to capture apps that were not bundles as well? I note after some testing that kind == "Application" vs ContentTypeTree == "com.apple.application"c lists differ by quite a few applications whereas the difference between ContentTypeTree == "com.apple.application-bundle and kind == "Application" is that the latter includes all the AppleScript apps on the target volume (using -onlyin /). Except by experiment, is there a reference for what to expect here? |
The documentation on 'mdfind' isn't the greatest. Here's the best I've found:
http://developer.apple.com/documenta...Ref/index.html http://developer.apple.com/documenta...uid/TP40001849 I'm not sure of the answers to your questions. I think I picked up the particular 'mdfind' query you ask about on some developer mailing list sometime. |
I'll have to develop a code with you Hayne, you help so often: TYAA == thank you as always.
The secret of "c" is revealed in your reference links: appending a c makes the query case sensitive. "d" makes the query insensitive to diacritical marks, and "w" renders the query word-based, and also detects transitions from lower-case to upper-case. |
Quote:
There is a list of UTIs here. There is also a pretty good article on how Apple has worked out UTIs and why here. Quote:
|
Thank you Bramley - I've been gathering some of that myself by reading the references Hayne provided, and I'm glad to have your ref to UTIs as well. Given those three references and some experiments by comparing the lists that result, I'll get it sorted.
|
A follow-on question
What is the format (and syntax) required for combining UTIs; i.e.; this and not that, or this AND/OR that? (assuming that is possible for mdfind searches - the man page and Hayne's reference docs are silent on that).
|
Quote:
http://www.hiram.nl/ipsedixit/artike...h-in-spotlight http://www.hiram.nl/ipsedixit/artike...t-in-spotlight No idea if it's of any help for the command line though. -HI- |
Turns out that setting a query to \"YourWords\" will find only files as it does for Spotlight, but OR is not a pipe (which after all has a special meaning in a shell) but is the word "OR".
http://developer.apple.com/documenta...ery/index.html describes the syntax of searches |
Quote:
which defines the same operators for the CLI that my previous GUI links did: The Power of mdfind (<-- 4 pages!) | pipe character means Boolean OR - minus means to exclude a term () parentheses create groups Part of the trick seems to be spaces : if used, they imply 'AND'. "Quotes" seem more useful in the CLI, 'cause in the GUI they will limit searches to filenames only (i.e., not contents). <?> I think. |
Thanks Hal;
Very useful. |
| All times are GMT -5. The time now is 01:08 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.