8 Replies Latest reply: Jul 28, 2008 4:14 PM by Antonio Rocco
Tohu Level 1 Level 1 (90 points)
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)
  • Tohu Level 1 Level 1 (90 points)
    No Way to do this?
  • red_menace Level 6 Level 6 (14,885 points)
    The metadata server and worker processes are always running. You might try checking the cpu usage of the mdworker process, or the modification date of the Spotlight database on the particular volume.
  • Andrew99 Level 4 Level 4 (1,300 points)
    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
  • Tohu Level 1 Level 1 (90 points)
    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.
  • Tohu Level 1 Level 1 (90 points)
    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?
  • red_menace Level 6 Level 6 (14,885 points)
    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.
  • Tohu Level 1 Level 1 (90 points)
    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.
  • Antonio Rocco Level 6 Level 6 (10,390 points)
    Hi

    Have you looked at mdutil? Consult the manual for usage: man mdutil.

    Tony