Automator doing actions more than once!

Hi,

I’m trying to write a folder action which takes image files from a folder and renames them before creating three differently sized versions with letters appended to the filenames to indicate which is which. There’s then an action to put all of these files together into another folder. The way I’ve come up with so far is clunky and long winded but it sort of works, apart from one thing - automator runs some of the rename actions more than once on each file before moving on… there’s no logic to it - in that it’s not always the same files or the same number of times, and it quite often continues to rename files for a couple of seconds after they’ve been moved in the last step.

I’m baffled - so any thoughts would be really helpful at this stage! Let me know if it’s helpful to post the file itself. My problem seems similar to the one in this post: http://bbs.macscripter.net/post.php?tid=25406 but it was never resolved - a workaround was found instead.

Thanks a lot everyone.

P

Hi,

there is a logic.
If you rename (modify) a file in a folder watched by a folder action, the folder action event handler takes those files as new added files.
It’s up to you, the scripter, to filter the modified files from being processed again :wink:

Stefan,

Thanks for taking the time to reply.

How would I do that? I assumed (perhaps incorrectly) that the Automator only processes one step at a time, before continuing on to the next? I already have a filter immediately before the rename action in an attempt to catch the repetitions, but it doesn’t help. How should I do this better?

A short excerpt from my Automator file would look a little like this:

  1. Get Specified Finder Items (the start folder)
  2. Get folder Contents (this could be a redundant step - I’m not sure)
  3. Filter Finder Items for JPEGs only and only filenames ending in – (the – suffix was added in an earlier step
    and is just so I can determine which files have been processed)
  4. Rename Finder Items (add “s” to indicate small)
  5. Move Finder Items (to the finish folder)

The filter I’ve got shouldn’t pass any files which have already been renamed as they would no longer end with --, instead ending with --s.
If I put a file called ‘test.jpg’ into this sequence, I get something like ‘test----llmmmss.jpg’ (the ‘l’ and the ‘m’ are large and medium, this happens earlier on). Note that it’s also doing this with the – stage too.

I’m still pretty new to this (though not to programming) so I’m sure I’ve missed something daft - any help would be gratefully received!

thanks,
pixel

Get Specified Finder Items and Get folder Contents are indeed redundant steps.
But this doesn’t cause your problems.
I don’t use Automator at all, because you can do all the things also in pure AppleScript (and mostly much better)
And without having the whole workflow it’s hard to give any reasonable advise

Wish I knew Applescript better, but in the meantime…
Here’s a Workflow version, though I threw a few of the processes around in the sequence just to make things a bit easier.

You’ll need to make 4 Path Variables and 1 Text Variable. For brevity mine are called “Path”, “Path 1”, “Path 2”, “Path 3” , and “Text”

In the workflow I’m placing the 3 folders in a single folder “Path” to keep things tidy.

[Ask for Text]
What do you want the save folder called?
(require an answer)

[Set Value of Variable]
Variable: “Text”

[New Folder]
Name: “Text”

[Set Value of Variable]
Variable: “Path”

Ignore input from the previous steps

[New Folder]
Name: Small
Where: “Path”

[Set Value of Variable]
Variable: “Path 1”

Ignore input from the previous steps

[New Folder]
Name: Medium
Where: “Path”

[Set Value of Variable]
Variable: “Path 2”

Ignore input from the previous steps

[New Folder]
Name: Large
Where: “Path”

[Set Value of Variable]
Variable: “Path 3”

Ignore input from the previous steps

[Ask for finder items]
Prompt: Choose files you want copied to the save folder & modified:
Type: Files
(allow Multiple Selection)

[Copy Finder Items]
To: “Path 1”

[Copy Finder Items]
To: “Path 2”

[Copy Finder Items]
To: “Path 3”

Ignore input from the previous steps

[Get Value of Variable]
Variable: “Path 1”

[Get Folder Contents]

[Rename Finder Items]
Add text
Add: S
after name

Ignore input from the previous steps

[Get Value of Variable]
Variable: “Path 2”

[Get Folder Contents]

[Rename Finder Items]
Add text
Add: M
after name

Ignore input from the previous steps

[Get Value of Variable]
Variable: “Path 3”

[Get Folder Contents]

[Rename Finder Items]
Add text
Add: L
after name

Probably the best place to put an image resize command action would be just after renaming the files.

To reassemble them into a single folder

Make a new Workflow

[Ask for finder items]
Type: Folders
{This is assuming you left them in the folders that were created in the Workflow above}

[Get folder contents]
(Repeat for each subfolder found)

[Filter Finder Items]
All of the following are true
Kind is not Folder

[Copy Finder Items]

If you want it to make a new folder and ask for a name for it you’d need to make 1 path variable and 1 text variable and basically do the same thing as in the first block of the first work flow.

Hope this helps.