Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is it possible to search Spotlight for an absence of an attribute in a file?

I use spotlight shell commands mdls, mdfind etc extensively. I can, for example, search for files having kMDItemCopyright being empty: (mdfind kMDItemCopyright=""). Some jpeg files (et al) do not readily have the exif metadata added to them, therefore the Copyright metadata would not even exist for spotlight to be able to judge it empty or not. Is it possible to ask spotlight for the absence of a metadata attribute such as Copyright?

Posted on Jul 13, 2014 5:31 AM

Reply
Question marked as Best reply

Posted on Jul 14, 2014 10:02 AM

Yes, you can ask mdfind to show you all image files that do not have a Copyright field available. I used $PWD for test containment. The ‘c’ is for case insensitive content; ‘d’ will show diacriticals if they exist, and ‘w’ is for a word search.


mdfind -onlyin $PWD ‘((* != “Copyright”cdw) && kMDItemKind == “*image”)'


Changing that negation to equality “==“ will show you images that do have the Copyright field available.


The following says to show all image files without a copyright that used PhotoShop CS in the image creation. Using CS* would show all CS versions.


mdfind -onlyin $PWD ‘((* != “Copyright”cdw) && (* == “CS”cdw) && kMDItemKind == “*image”)'


Or, all the images without Copyright that use CMYK in their kMDItemProfileName field.


mdfind -onlyin $PWD '((* != "Copyright"cdw) && (* == "CMYK"cdw) && kMDItemKind == "*image")'


Or, all the images without Copyright, that may have a copyright string in the Authors field (as my Nokia N9 does).


mdfind -onlyin $PWD '((* != "Copyright"cdw) && kMDItemAuthors == "@*" && kMDItemKind == "*image")'

2 replies
Question marked as Best reply

Jul 14, 2014 10:02 AM in response to sangak

Yes, you can ask mdfind to show you all image files that do not have a Copyright field available. I used $PWD for test containment. The ‘c’ is for case insensitive content; ‘d’ will show diacriticals if they exist, and ‘w’ is for a word search.


mdfind -onlyin $PWD ‘((* != “Copyright”cdw) && kMDItemKind == “*image”)'


Changing that negation to equality “==“ will show you images that do have the Copyright field available.


The following says to show all image files without a copyright that used PhotoShop CS in the image creation. Using CS* would show all CS versions.


mdfind -onlyin $PWD ‘((* != “Copyright”cdw) && (* == “CS”cdw) && kMDItemKind == “*image”)'


Or, all the images without Copyright that use CMYK in their kMDItemProfileName field.


mdfind -onlyin $PWD '((* != "Copyright"cdw) && (* == "CMYK"cdw) && kMDItemKind == "*image")'


Or, all the images without Copyright, that may have a copyright string in the Authors field (as my Nokia N9 does).


mdfind -onlyin $PWD '((* != "Copyright"cdw) && kMDItemAuthors == "@*" && kMDItemKind == "*image")'

Is it possible to search Spotlight for an absence of an attribute in a file?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.