|
|
#1 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
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?
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) Last edited by NovaScotian; 12-19-2006 at 12:25 PM. Reason: Correction |
|
|
|
|
|
#2 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
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.
__________________
hayne.net/macosx.html |
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
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.
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) Last edited by NovaScotian; 12-19-2006 at 01:48 PM. |
|
|
|
|
|
#4 | ||||||||||||||||||||||||||||||||||||||||||||||
|
MVP
Join Date: Apr 2004
Location: Cumbria, UK
Posts: 2,461
|
It should be so. The UTI 'com.apple.application' should mean all applications (although some forms of executable code are not covered - libraries, frameworks and the like) The UTI 'com.apple.application-bundle' should be all .app applications. And 'com.apple.application-file' should cover applications contained within a single file, such as compiled Applescripts. There is a list of UTIs here. There is also a pretty good article on how Apple has worked out UTIs and why here.
Not sure about the first example, but in the second one 'com.apple.application-bundle' will only include applications that are bundles - no applications as files are included. kind == Application will include all bundles and files that are applications. |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#5 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
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.
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) |
|
|
|
|
|
#6 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
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).
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) |
|
|
|
|
|
#7 | |||||||||||||||||||||||
|
Hall of Famer
Join Date: Apr 2002
Posts: 3,315
|
Here are some links showing how to do that in the GUI: 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- |
|||||||||||||||||||||||
|
|
|
|
|
#8 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
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
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) Last edited by NovaScotian; 12-27-2006 at 08:28 PM. Reason: Changed Conclusion then added info |
|
|
|
|
|
#9 | |||||||||||||||||||||||
|
Hall of Famer
Join Date: Apr 2002
Posts: 3,315
|
Hmm, I haven't used mdfind all that much. But I did 'find' another web page 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. Last edited by Hal Itosis; 12-28-2006 at 08:36 AM. |
|||||||||||||||||||||||
|
|
|
|
|
#10 |
|
League Commissioner
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 5,155
|
Thanks Hal;
Very useful.
__________________
17" MBP, OS X; 27" iMac, both OS X 10.10.x (latest) |
|
|
|
![]() |
|
|