I posted a while ago about problems I was having with Spotlight and .docx files. I thought I had fixed the problem, but apparently that is not correct. This issue is Spotlight simply is not indexing my .docx files. This is happening on all three of my Macs. Spotlight will index the file name and searching for a file name works fine, but it won't search the contents of the document so I can't find a file using a keyword search. This appears to only be a problem on .docx files as I can create a new .doc file and it indexes immediately. I have tried re-indexing Spotlight, both through adding my drive to the Privacy tab and then removing it and through the Terminal command sudo mdutil -e/
This didn't work as both methods re-indexed the drive, but still left out .docx files (in terms of content). I found a post on Apple's Forums that gave a Terminal command, find ~ -type f -name '*.docx' -print -exec mdimport -d1 {} \; which did fix the problem for existing files as they are all now searchable under Spotlight, Finder and Siri, but new documents and changes are still not indexed. The author of the post mentioned that he has created a script, posted below, that he runs every hour to keep track of newly changed and created documents, but I have no idea how to make my Mac run it automatically. He mentioned Cron, which I have no idea what that is, and I found another post that said make the script a plist and use launchd. Can someone help me figure out how to automate this script so that my new and changed Word documents will be searchable? Thank you.
This didn't work as both methods re-indexed the drive, but still left out .docx files (in terms of content). I found a post on Apple's Forums that gave a Terminal command, find ~ -type f -name '*.docx' -print -exec mdimport -d1 {} \; which did fix the problem for existing files as they are all now searchable under Spotlight, Finder and Siri, but new documents and changes are still not indexed. The author of the post mentioned that he has created a script, posted below, that he runs every hour to keep track of newly changed and created documents, but I have no idea how to make my Mac run it automatically. He mentioned Cron, which I have no idea what that is, and I found another post that said make the script a plist and use launchd. Can someone help me figure out how to automate this script so that my new and changed Word documents will be searchable? Thank you.
Code:
#!/bin/bash
# forces spotlight to re-indexing of .docx files in a range of modification/creation times.
# does this by running the "mdimport" command on the appropriate .docx files.
# this is intended to be run at least once every 24 hours.
# setup time stamp file.
time_stamp=~/.time_stamp_file.txt
# set time stamp file to current date/time.
touch "$time_stamp"
# adjust the date back in time 24 hours.
touch -a -240000 "$time_stamp"
# index .docx files that were modified since the time stamp file.
find ~ -type f -name '*.docx' -newer "$time_stamp" -print -exec mdimport -d1 {} \;
exit