MacOS – Automator’s Finder Actions: “Unable to search with Spotlight”

automatorfinderhigh sierramacosspotlight

I created a workflow like this after asking another question:

enter image description here

It should delete downloads older than 30 days, and has been working fine until today; today I updated to macOS High Sierra.

Now whenever the Application tries to run I'm getting the error

enter image description here

The action "Filter Finder Items" encountered an error: "Unable to search with Spotlight"

How can I fix my workflow so that it works with this latest version of macOS?

Best Answer

As a (temporary) workaround, I'd use the find command.

In a new Automator workflow, add the following actions:

  • Run Shell Script

    • Settings - Shell: /bin/bash and Pass input: to stdin
    • Replace the default cat with:

      find "$HOME/Downloads" -maxdepth 1 -type f -mtime +30d -iname '*.*'
      
  • Move Finder Items to Trash

  • Save the workflow as an application.

Note: As coded, this only deletes files at the directory level of ~/Downloads. It does not traverse subdirectories, so as to avoid deleting something Safari is downloading at the time it's run, as it uses a .download bundle which is a directory. You could devise a more complex find command and or workflow, however this, as is, is better then your current nonfunctioning workflow.