I've been trying to make an Automator droplet that removes files of a particular extension from a directory. My Workflow has 3 actions (when I'm not debugging):

  1. Get Folder Contents (Repeating for each subfolder)
  2. Filter Finder Items (File extension is "part")
  3. Move Finder Items to Trash

It's #2 that seems to be giving me problems. No matter what I do, no files ever pass through its filter. When I expand the results for Get Folder Contents and any other Finder actions, I always see files in the results. But even when I specify the most permissive filters, this action never produces anything.

If you want to debug this, just insert a new action up top: Get Specified Finder Items, dropping on any directory that has any files within it - although technically the "Filter Finder Items" should also be able to return folders.


I'm now on Lion, and seeing the exact same behavior. I also tried replacing step 2's criteria with "Name ends with 'part'" but that didn't make a difference either. I ultimately ended up writing an AppleScript that accomplished the same task (see below).

  • Cannot reproduce. Both "py" (Python source code) and "trec" (not known to the system) work. Get Specified Finder Items -> Get Folder Contents -> Filter Finder Items. – Daniel Beck Nov 5 '10 at 9:08
  • You could try running the Mac OS X combo updater for your current version again. Sounds like there might be an issue with older/incompatible Automator actions. Have you upgraded from a previous Mac OS X version? – Daniel Beck Nov 5 '10 at 9:09
  • Yeah, I upgraded way back when Snow Leopard first came out, and I've kept up to date.... How would I repair Automator? Copy from another system? – Dov Nov 5 '10 at 10:50
  • I also just reproduced this on my other Snow Leopard machine in the house with the same file. – Dov Nov 6 '10 at 11:11
  • Can you reproduce with arbitrary file extensions? Is "part" the real file extension, or is it maybe in the form ".part.xxx" with ".xxx" hidden in Finder? – Daniel Beck Nov 6 '10 at 16:23

check your spotlight privacy preferences. If the folder you are working with is not being indexed by spotlight, then the filter command will find nothing.

  • Could be the rub. I couldn’t reproduce the bug when testing, but I tested inside my home folder (i.e. in an indexed area). – kopischke Nov 10 '11 at 10:49
  • That was definitely the piece of missing information. That never even occurred to me. I have to wonder, though, why there isn't a way to filter a selection that isn't Spotlight-indexed. – Dov Nov 18 '11 at 16:12

It seems newly added files to a folder (as in earlier in the workflow) seem to be missing from the results. For example, see my attached image of my workflow (the first is just a get folder contents).

enter image description here

  • 1
    So, what are you suggesting? I just tried setting the Filter Finder Items criteria to "Name ends with .part", analogous to your example, but still, no files come through. Also, I'm on Lion now. – Dov Sep 30 '11 at 12:27

I wrote an AppleScript to accomplish the same task, but I won't accept this answer, since I still think something's wrong with Automator (or I'm not understanding something fundamental about it). This is the AppleScript for a droplet that accepts one or more folders and removes all files ending with .part and has been working flawlessly for months, now (on Snow Leopard and Lion).

on open theItems

    repeat with theItem in theItems
        set theInfo to info for theItem

        --Verify dropped items are folders
        if not folder of theInfo then
            my warnUser(theInfo's name)
            --Empty out the .part files
            my removePartFiles(theItem)
        end if
    end repeat
end open

on run
    my warnUser(missing value)
    -- Used for debugging
    --my removePartFiles("Macintosh HD:Users:Username:Some Test Folder:" as alias)
end run

-- Calls itself recursively
on removePartFiles(RootDirectory)
    tell application "Finder"
        delete (every file of RootDirectory whose name ends with ".part")

        set subFolders to folders of RootDirectory
        repeat with eachFolder in subFolders
            my removePartFiles(eachFolder)
        end repeat
    end tell
end removePartFiles

on warnUser(itemName)
    set msg to "Please drop folder(s) onto me"
    if itemName is not missing value then set msg to "'" & itemName & "' is not a folder"

    display alert msg as warning buttons {"OK"} default button "OK"
end warnUser

This answer from Apple's support site explains it. The files need to have been indexed and show up in Spotlight before they can be found with a search in this manner.

Reference: Automator Filter Finder Items

The Find Finder Items and Filter Finder Items actions use spotlight metadata to produce their results. This means that any disks, folders, or files that you input into them must be indexed by spotlight, otherwise the actions will return an empty list. Open the Spotlight pane of the System Preferences app and check the following:

That the kind of file you are looking for is enabled in the Search Results tab. That the folders you are working with (or their parent folders or disks) are not excluded from spotlight in the Privacy tab.

As a rule, these two actions will work precisely the same way as a Finder search (using command-F), so you can double-check to see what results you will get that way.

also, when searching by file extension, don't include the dot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.