Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator Filter Finder Items

A very simple task, which I have attempted to figure out many times over the last few months; but my repeated attempts haven't been successful. This should be easy for someone to resolve…


I would like to strip out all the files of a certain extension (.txt) from an hierarchy of nested folders, & move them to the Trash. (Told you it was easy!)


Here's what I think ought to work:


• Create an Automator Workflow

• 'Ask for Finder Items' to select the topmost folder

• 'Get Folder Contents' with 'Repeat for each subfolder found' — (the results successfully include all the relevant files)

• 'Filter Finder Items': "find files where any of the following are true: file extension is .txt" — (I tried "txt" as well as ".txt")

• 'Move Finder Items to Trash'.


The files turn up (alongside loads of other junk) in the 'Get Folder Contents' step, & they are reported in the results; but when I try to filter out everything apart from the .txt files, so that only the .txt files remain, the filter reports no results.


So the 'Filter Finder Items' action completes with no results, & with a warning that: The action “Move Finder Items to Trash” was not supplied with the required data.


I think it must be something obvious, but I can't figure it out, & although I've searched extensively online, everyone else with similar problems has other complications which get resolved… so they lose interest just at the point where I think they're going to reveal the solution.

27" iMac 3.06 GHz Intel Core 2 Duo, Mac OS X (10.6.5), Logic Studio 8.0.2, Occam's Razor Pro

Posted on Jun 18, 2011 5:15 AM

Reply
21 replies

Jun 21, 2011 2:36 AM in response to twtwtw

I have several 2Tb external hard drives, & in order to save time & prevent unwanted & unnecessary duplication of effort I told Spotlight not to index them. So it looked as if the Spotlight Privacy list might be the culprit.


To test this, I copied a large folder full of JPGs from an external drive to my boot drive, altered the Filter Finder Items step to search for .jpg, & ran the workflow. "No results were produced".


I thought perhaps Spotlight hadn't finished indexing, so I waited & tried again. Nothing. So I found a small folder which had been on my boot drive forever & tried the workflow on that; nothing.


Then I found out that when specifying the File extension, you shouldn't include the period! (As discussed in the OP.)


Now it works, including the Move Finder Items to Trash action (which is, however, very slow).


twtwtw, if you would like to recapitulate these findings in a new post, I will mark it as "Correct Answer" so that anyone else having similar issues can find out quickly that Spotlight needs to have already indexed files for these actions to work, & that therefore a quick look in the Spotlight Preferences Privacy Pane is worth a go…!


Many thanks to the three of you. I feel reinvigorated.

Jun 21, 2011 12:00 PM in response to Caramby

lol - okie dokie. recapitulating:


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! 🙂

Jan 26, 2012 11:33 AM in response to Caramby

okay, I found out something interesting. I got this to work, but one thing I learned is that the filter will NOT accept any backslash or forward slash when looking for a name.


What worked for me:


enter in under "workflow"

go to 'files & folders'

then add: ask for finder items, get folder contents, and filter finder items


in ask for finder items, select the actual folder that contains the files you want to find

in get folder contents select the box "repeat for each subfolder found"

now, if you are looking for a file by it's name or what it begins with you should

have in the filter :

-all

-kind is not folder

-name begins with (enter what you want to search for here)


press play and, again, select the folder that you selected on the first step. then press choose.


you will then see the files that you were looking for.


you can then add the move to a folder option if you want to move it to another folder, or move to trash.


it should work. I am in Lion OSX with the latest updates.

Automator Filter Finder Items

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.