What means "after receiving added_items"?

Hallo,
I would like to understand my folder action script fully to be able to find out,
why it sometimes takes ages to get things done and sometimes it is very fast…

What does “after receiving added_items” mean in on adding folder items to this_folder after receiving added_items?

Are Folder Action Scripts single-threaded, so if two files are involved at the same time, can problems occur?
How will Apple Script process subsequently added items?
Let’s say file one is copied in and while file one is still copying file 2 comes in.
Let’s say file two is earlier ready than file 1.

Is it possible, that this scenario slows the processing of file 1 down considerably?

Regards

Ute

Receiving added_items is the trigger for the folder action which triggers when the folder contents are increased.

All AppleScripts are single-threaded.

If items are added sequentially and the process that is triggered is lengthy, subsequent items can be missed.

That is possible, depending entirely on what you are doing in the action.

It’s a “labeled parameter” of the adding folder items to handler. The label is after receiving and added_items is a variable. Each time the handler’s triggered, the variable receives a list of the item(s) whose addition to the folder triggered the script. Items that were already in the folder are not included in the list, so the code in the handler can refer to this variable to identify the latest additions to the folder. You can call the variable whatever you like, as long as it comes after after receiving in the top line of the handler.

Similarly, this_folder is the “direct parameter” of the handler (it doesn’t have a label) and is a variable that gets set to the folder concerned. You can call this variable anything you like too.

on adding folder items to this_folder after receiving added_items
	display dialog (this_folder as text)
	repeat with this_item in added_items
		-- Do something with this_item
	end repeat	
end adding folder items to

See also: adding folder item to