I’ve had some ongoing issues with some Mac users at work recently who were complaining about the length of time that it was taking for Finder to open up some of our network shares. At first, I thought that the issue may have stemmed from our backups that happened to be running at the same time, but after I figured out how to make those processes run in the background and only when the system was idle and that the problem was still prevalent, I had to investigate further.
Upon further inspection, I found that the folders in the network drives they were accessing and sometimes taking up to a minute or more to populate, in most cases had several thousand files and subfolders. After the initial loading of the folder, everything was still easily accessible and readily available after that if you left that directory and came back into it, so chalk it up to a folder caching/indexing issue.
Thanks to this feller here for the useful giblet of info.
Here is how you can force Spotlight to index a network drive:
Enable Spotlight indexing on a mounted Volume
sudo mdutil /Volumes/shareName -i on
Disable Spotlight indexing on a mounted Volume
sudo mdutil /Volumes/shareName -i off
Check the indexing status of mounted Volume
sudo mdutil -s /Volumes/shareName
And as a perfect candidate for an after hours cron job, here’s how to force a reindex of a mounted Volume
sudo mdutil -E /Volumes/shareName
Or to reindex all drives
sudo mdutil -pEsav