Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question
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 "" with ".xxx" hidden in Finder? – Daniel Beck Nov 6 '10 at 16:23
up vote 1 down vote accepted

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.

share|improve this answer
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

share|improve this answer
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
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .