I have a certain set of PDFs downloaded from a free library that I'd like to search, from time-to time. For that, I'd like to use a shell script, that performs an 'mdfind' command. Since I've got a lot of PDFs on my computer, I do not want kMDItemTextContent to be performed on each and every one of those PDFs.. I only want to search that certain set of PDFs.
My problem is, that when I spotlight search those PDFs -for example they all have a certain word in their filenames- all the 13 PDFs would pop up among the results, BUT when I use mdfind to search PDFs in a certain folder, only 2 shows up.
Here is what I use:
mdfind -onlyin '/Users/folder/folder/folder with spaces/' 'kMDItemContentTypeTree=="com.adobe.pdf"'
Can anyone tell me why?!
UPDATE: the above is only about finding the right PDFs, not about the actual text search..
mdfind was also missing a few PDFs in my books folder:
$ comm -3 <(printf %s\\n ~/Documents/books/**/*.pdf | sort) <(mdfind -onlyin ~/Documents/books kMDItemContentType=com.adobe.pdf | sort) | wc -l
6
mdimport ~/Documents/books didn't help, but it found all of those files after I rebuilt the Spotlight index with sudo mdutil -Ea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With