I have a file that can be shown with the following command.

$ mdimport -d2 file.pdf

But when I use the following command to search for the file. The file won't show up immediately.

mdfind -onlyin dir_the_file_is_in "(kMDItemTextContent=='searchterm'c) && (kMDItemFSName=='*.pdf')"

After I wait for sometime since I open it with Acrobat, then the above mdfind command will find it. Furthermore, I actually can not tell whether it is because I used Acrobat to open the file or because I used mdimport -d2 file.pdf so that the file can be found as I did both.

Does anybody know why this is the case?

  • Using mdimport -d2 [file] doesn't do anything-- it prints an error message about how the command line options are wrong. so it's hard to tell what you're doing here. Feb 24, 2020 at 21:02
  • mdimport . takes a lot of time (1 minute for PDFs of about 600MB) to run on my Mac. If it does not perform indexing on the fly, why does it take a long time to run? Feb 26, 2020 at 16:05
  • Spotlight normally does index on the fly. I've never checked too closely but 1 minute for 600MB doesn't seem unreasonable. I still don't know what problem you're trying to solve here. Feb 26, 2020 at 23:06
  • @TomHarrington The problem is my files are not necessarily found in the spotlight index. I'd like to make sure that they are always in a spotlight index. Feb 28, 2020 at 15:51


You must log in to answer this question.

Browse other questions tagged .