folder actions - repeat bug

Hi,
ideally, folder actions are a really cool feature. In practice, this system has some limitations. Lately i used this system at a daily basis and i saw that folder action scripts use to process chunks of files. Lets say, if i drop 10 files on a folder with an folder action script attached, the script starts twice, (taking first 5, then the other 5 files) which isn’t a desirable effect in my opinion.

Somebody found a workaround for this issue ?

What is your script supposed to achieve ?

I would not be surprised if you are renaming the dropped files in the target folder.
In this case, the renamed files are treated as newly dropped ones and the system is fooled.

Never rename files in the folder in which we drop them. Always move them in a final destination folder which has no attached script.

Yvan KOENIG (VALLAURIS, France) jeudi 26 juin 2014 12:12:59

Why isn’t that the desired results? Is there a difference in results, even if your script started for each file individually?

All files have to be added within a time window. That time window isn’t long. Let’s say if you copy a 1000 files to a folder which takes an average of 3.6 seconds for each file to copy (total time an hour). Would you prefer a single folder action after one hour to process all 1000 files or do you prefer 100 folder actions processing 10 files each? So I would say that this is not a bug, it’s an undocumented feature.

But you asked for a workaround. The easiest workaround would be gathering all files in a folder and move that folder to the folder that has the folder action attached to. But that’s probably not the answer you were looking for.

Hi Joy,

One workaround is to use a droplet instead of the folder action.

gl,
kel

@Ivan Koenig: no renaming, but thanks for the tip. My folder action script asks in which subfolder i want to put the added files. But it looks strange for me, that the script executes twice, with 10! files only.

@DJ BazzieWazzie: i understand the concept, thanks nevertheless. However, you talked about 1000 files ( where the concept makes sense for technical reasons) and i of 10, which is a very small amount of files. Probably the concept doesnt change, because i spend some seconds to answer dialogs. Seems that fasc continues to loop the same script after n-seconds till the files are .? sorry, but what does expect the loop exactly?

Everytime i add files to the folder in question, my script asks me in which subfolder i wish to put the new added items. The destination per drop is always the same, so ive to answer twice, which isnt nice.

Maybe a repeat-routine inside my script could help to process all the added items?

@kel : thanks, good idea.

Folder action scripts

issues.
First, good news: i found a workaround for my previous issue by adding a handler, instead to put my script directly into the “on adding folder items” handler (at last valid for 10.7.4)

on adding folder items to this_folder after receiving these_items
	my outsource(this_folder, these_items)
end adding folder items to

on outsource(this_folder, these_items)
	#my script
end outsource

But i found other issues as well. Results can vary, especially when involving workflows.

processed 3 instead of 4 files (always one file is missing)

processed only 1 of 4 files

error, that my script couldn’t be executed. Funny, because its always the same script -depends sometimes on a technical time-frame, but not always. Workflows and automator plugins seems not to be very well team players with applescript.

suggestions?

The absolutely most reliable way to do this is to use Hazel, unfortunately $28, but essential to me.

Ok, thanks -Adam.

A last thing i wanted to know is, if im the only one to experience the issues described in my post before.
Folder action scripts that:

process 3 on 4 files (always one file is missing)

process only 1 of 4 files

error, the script couldn’t be executed.

.also, but not only in conjunction with (Automator) workflow scripts.

You’re not. :slight_smile: I spent some time looking at the problem this morning and found exactly the same thing, for which I was unable to find a reliable workround. The problem seems to be the script being triggered before all the new items have been added to the folder ” or at least before they’ve been added to the list of aliases passed to the handler.

Do you get different different behaviour when moving or copying files?

Hi ktam,

i dont think moving or copying makes the big difference. The problem with folder action scripts is the time-frame within folder actions are executed. If i drop items using this handler structure:

on adding folder items to this_folder after receiving these_items
   my outsource(this_folder, these_items)
end adding folder items to

everything works fine. But if i continue to put items in short time intervals, folder action scripts stops to work correctly.