Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Verify if Spotlight is indexing

Hello.

is there a way to verify if sotlight is indexing at the moment within Apple Script? Maybe even if it is indexing an given Volume?

Mac OS X (10.5.2)

Posted on Jul 21, 2008 6:51 AM

Reply
8 replies

Jul 26, 2008 8:59 AM in response to Tohu

Tohu,

The code below would need to be saved as a stay-open application...

*on idle*
*tell application "System Events"*
*do shell script "ps -Aco command"*
*if result contains "mdimport" then*
*display dialog "mdimport is running..." buttons {"OK"} default button "OK"*
*if button returned of result is "OK" then*
*quit me*
*end if*
*end if*
*end tell*
*end idle*

Since it's likely that mdimport is not currently running, you can test the script using any of the currently running processes, visible or not, found under All Processes in Activity Monitor, by replacing each instance of "mdimport" with the name of another running process. Also test the script using a readily available application currently not running by replacing "mdimport" with its name. Launch the script, wait a bit, and launch the application named in the script. The dialog telling you the app is running should appear within 30 seconds. Pressing "OK" will quit the script within 30 seconds.

That said, you might consider whether keeping a stay-open script app running is worth the bother. Might be easier just to check Activity Monitor periodically. Good luck.

Regards, Andrew99

Jul 26, 2008 9:28 AM in response to Andrew99

I put the code in scripteditor and hit "Run" at that moment spotlight was indexing an volume. Nothing happend. Also i have no "mdimport" process but i do have lots of "md...".

But if i understand what it should do if it works, telling me spotlight is indexing but not wich volume, doesnt help me. But thx for the idea.

Jul 26, 2008 9:33 AM in response to red_menace

Hi.
How to check the modifikation date of the database on the particular volume in apple script?

If the volume werent indexed at the time it gets mounted, is there maybe no database so spotlight creates one? If so, is there a way to let AS check if an database is on that volume at the time it gets mounted?

Jul 26, 2008 10:17 AM in response to Tohu

The mdworker process is what scans and indexes file as a volume is mounted, but it is always running (just more at times). Each volume that is indexed has a Spotlight database file on it - it is normally invisible, but the normal methods to get information about the various file (such as modification dates) can be used.

What exactly are you trying to do? There may be another approach.

Jul 26, 2008 11:34 AM in response to red_menace

My Back Up Volume should be in Spotlight privacy because i don't wont do have every entry in the search results twice. I don't use Time Machine and need to erase the Back Up volume before i clone my whole system to it. After erasing the volume it dissappears in spotlights privacy settings. Ok that is because the volume gets an new id. So i put it back to the privacy setting. Unfortunately the next time the volume gets mounted the privacy setting is gone again and that is the problem. That only happens once after i cloned my system but this is nerving. So i need an process that runs all the time in background or an AS that gets started if the Back Up Volume gets mounted. The process or AS should then put that volume back into privacy settings. For that i have allready an script. All i need is a way to check if spotlight is indexing this volume.

Sadly Apple don't give an easy option that an volume with a specific name gets never indexed.

Verify if Spotlight is indexing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.