Is not working. I tried with all possible combinations of quotes.
This works: mdfind ‘kMDItemAuthors == *Luciano’ → 2
This is also works: mdfind ‘kMDItemTextContent == *Luciano’ → 99
But the two together, such as: mdfind (‘kMDItemAuthors == *Luciano’ &&! ‘kMDItemTextContent == *Luciano’)
doesn’t work … with this error. -bash: syntax error near unexpected token `‘kMDItemAuthors == *Luciano’ ’
You should include [c] if you want the search case-insensitive. Here it is using Metadata Lib:
use script "Metadata Lib" version "2.0.0"
set theFolder to choose folder
set theMetadata to perform search in folders {theFolder} predicate string "kMDItemAuthors ==[c] %@ AND kMDItemTextContent !=[c] %@" search arguments {"*Luciano*", "*Luciano*"}
is there any quick way to exclude one attributes (kMDItemTextContent) from the search?
Let’s say I want to search for the word “the” in my files and find those files where it is present either the name, or author or in the comments etc… but not in the kMDItemTextContent, otherwise all files will be positive.
This is the script I am using so far. It works, but I would like to include in the search all fields (=attributes) but not kMDItemTextContent.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Metadata Lib"
# the clipboard contains the string I want to find
set MyDoi to the clipboard
set theFolder to alias "iMac_HD:Users:ldicroce:Desktop:for_ERC:"
set {a1, a2, b1, b2, c2} to {"kMDItemDescription", MyDoi, "kMDItemFinderComment", MyDoi, ".pdf"}
set theMetadata to perform search in folders {theFolder} predicate string "%K CONTAINS[c] %@ OR %K ==[c] %@ AND kMDItemFSName ENDSWITH[c] %@" search arguments {a1, a2, b1, b2, c2}