Why is Automator not working with Spotlight Search

automatorspotlight

I'm running an Automator Workflow that searches a provided directory, and then does a standard Filter Finder Items in order to make sure it's only going to be working with aliases.

Spotlight failed to find the file named "NUCLEUS SOUNDLAB Pantheon III.rfl." Please make sure privacy has not been enabled for this file in System Preferences. (-212)

The files being processed are on an external HD mounted over Firewire 800. I definitely do not have any privacy settings in spotlight at all.

Since it appears that the Spotlight index may be hosed and not working, I have been scouring for ways to force it to reindex the specific directory containing the file it's complaining about. Thus far, all attempts have failed:

  • Tried adding the HD to and removing it from privacy, no indexing
    occurred.
  • Tried using mdutil at the command line, no indexing
    occurred.
  • Tried removing all .spotlight references and reindexing, no
    indexing occurred.
  • Tried unmounting/remounting and rebooting, no change.

I'm at a loss as to what else to do. If I remove the "offending" file from the directory being searched in the workflow, it STILL throws the error on it – even if it's moved to a completely different volume and is very clearly NOT listed in the automator results of the task that succeeded prior to the Filter Finder Items task.

How can I get past this issue?

Best Answer

What happens if you try in terminal.app (change /Search/Directory/ to yours):

mdfind -onlyin /Search/Directory/ kMDItemFSName == "\"NUCLEUS SOUNDLAB Pantheon III.rfl\""

Or in applescript editor.

    set searchPath to "/Search/Directory/"

    set this_item to "/Users/USERNAME/Desktop/NUCLEUS SOUNDLAB Pantheon III.rfl"

    set theFileName to "\\\"" & (do shell script "basename " & quoted form of (POSIX path of (this_item))) & "\\\"" as string

--set theFileName to quoted form of (do shell script "basename " & quoted form of (POSIX path of (this_item))) as string

  set theOrigFilePath to paragraphs of (do shell script "mdfind -onlyin " & searchPath & " kMDItemFSName == \"" & theFileName & "\"")