Apple Automator Mavens?

Stephen Marsh

Well-known member
I seem to have a love/hate relationship with Apple Automator.

Some things work as intended, nice and easy.

Other things that should be easy either don’t work as intended or I am missing something that should be “obvious”.

Is anybody out there proficient with Automator?

For example, I often take screen captures, however they are tagged with my monitor profile which is large. I would like to automate converting to sRGB using a folder action set to my desktop. The issue is that no matter what combination of settings I use to get finder items or filter finder items based on file name, file type, extension etc. the Automator action will try to convert files that don’t match the filter rules.


Stephen Marsh
 
I've found folder actions to be pretty unreliable. I can take a look at your scripts to see if I see an error but I had to stick with straight applescript and a program a friend wrote to monitor the folders.
 
I've found folder actions to be pretty unreliable. I can take a look at your scripts to see if I see an error but I had to stick with straight applescript and a program a friend wrote to monitor the folders.

Thank you for the reply Mikie!

Folder Action example:

Filter Finder Items:All/Name/Contains/18000
New Text File…
New Mail Message

The goal is that if the watched folder has a new file added that is titled “filename_18000.jpg”, then an email should be created with a new text file. If a file such as “filename_00001.jpg” is added, a new email should NOT be generated (as 00001 is not 18000). However if a file name contains say 00001, the folder action is triggered when this does not match 18000. My understanding is that the Filter Finder Items should only pass on a file if the name contains 18000 for example. It could be ANY file added to the folder, even a file without a number in it’s filename that triggers the automator workflow.

So, is it possible that a Folder Action will simply process any files input into the folder, irrespective of the conditions put in place to limit the processing? Is my expectation wrong that I should be able to use a “filter finder items” to limit the processing? Same goes for “get finder items” or “find finder items” when used in a Folder Action.


Stephen Marsh
 
Last edited:
Automator doesn't work that way in my experience, you will have to have an applescript to filter the name conditions because automator is a workflow, there is no IF/THEN logic. It does look like it should work when viewing it in automator, but nope it's just a simple workflow handler. Step one: Filter names. Step two: create text. Step three: email. It does all of that, but like I said there is no IF/THEN so it jsut goes through the steps.

You may have better luck on the apple forum though, I gave up on folder actions a few years ago. Applescript and extenscript for me, sometimes I even write applescript INSIDE of extendscript :)

sorry I couldn't be of more assistance.
 
Thanks again for the reply Mikie. I guess this explains the mixed results with Folder Actions vs. say Services etc.

I have spent a few days trawling the internet for AppleScript or Shell Script code for use as a conditional if/else filter without any luck. The search continues…


Stephen Marsh
 
Hello Stephen,

In my experience Mikie is quite correct.

If you really want to avoid the applescript route you can create IF/THEN routines by passing files to other folders that have Automator folder actions for the next stage of the workflow. It's clunky and slow but it can work.
 
Last edited:
Hello Stephen,

In my experience Mikie is quite correct.

If you really want to avoid the applescript route you can create IF/THEN routines by passing files to other folders that have Automator folder actions for the next stage of the workflow. It's clunky and slow but it can work.


Mikie Mikie


Thanks Tim, I did try that, however the goal was:

* Automated, hands free with no operator intervention

* If a file is found in a folder with 18000 in the filename, trigger an email (but don’t trigger an email if any other number is found in a file name).

I could not get this to work chaining two folders together, as each time the folder action would stump me.

It is not that I wish to avoid using an AppleScript or Shell Script – it is just that I can’t write one and I cant find any available code to work as a conditional if/then filter.

I did find and install something that sounded promising, an Automator action created by a third party “Stop If Input is Empty”, however it either does not work with later OS versions or I used it incorrectly.

This is not a big deal, it is more of a challenge than anything!


Stephen Marsh
 
Hello Stephen,

​Hey, thanks to you I found the "create_CMYK_scatter.app"

The least I can do is return the favour for all the time that thing has saved me. :)


You can add a "Run Applescript" action in Automator.


on run {input, parameters}

if ((input) as string) does not contain "18000" then


-- do nothing and quit

display dialog "I quit" -- remove this line after testing

quit

end if
return input
end run



You should be able to copy and paste this text into the Automator Applescript Action.

It will replicate the “Stop If Input is Empty” action.

Save your work often as every time you test your workflow
Automator will try to Exit as you hit the "Quit" command.

Keep the display dialog for as long as you can so Automator does not quit when you are not ready.


The workflow will carry on running as long as
input contains "18000"

The
screen shot attached shows my test app.

Any problems, just let me know.
 

Attachments

  • Screen Shot 2016-01-03.pdf
    212.9 KB · Views: 316
Last edited:
Thank you Tim, no problems – it worked beautifully, just as Apple should have done out of the box! :]

P.S. I don’t recall the topic thread or post that lead to you finding the “create_CMYK_scatter.app”, however I am glad to have helped in the past!


Stephen Marsh
 
Last edited:

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top