Automator application needs to ignore all files that aren’t EPS

applescriptautomatorfinder

I've made an application that I drop EPS files on and it makes two copies and renames them and transfers them to SMB shares.

But sometimes when I have more than one file selected in other windows, Finder passes multiple files onto Automator. All I really need it to use are EPS files, ignoring others and passing the EPS files on to automator for renaming.

I pass variables onto an applescript for if statements. My first attempt:

on run {input, parameters}

    if (input as text) does not contain ".eps" then
        tell application "Auto 45" to quit
    else

    end if

    return input

end run

Then I realized that this doesn't do anything about multiple files. If it finds .eps anywhere in all files combined into a single variable, it simply passes all kinds of junk files through.

I tried to use this if statement instead:

tell application finder
    if name extension of (input) is "eps" then
        #if (input as text) is equal to type "eps" then
        return input
    else
        nothing
    end if

end tell

This code doesn't work even though it compiles, nor does this solve the problem of checking multiple inputs. I'm using the Mavericks version of Automator.

Best Answer

The solution for your problem is the Filter Finder Items action.

Just add it to your workflow before your AppleScript Action.