Unexpected "On Open" Behavior

I’ve discovered that when a combination of files and folders are dropped on an On Open applet, the items are processed twice. First, the folders are processed, then the handler executes again, processing the files. This makes it difficult (impossible?) to get a single list of all the items dropped before further processing.

For example:

on open droppedItems
	say (count droppedItems)
end open

If the following five items are dropped…
2024-11-17_17-21-33

…the script will say “Two Three”, not “Five”. It runs twice: first for the folders, then for the files.

Interestingly, this is not the case while using SD’s Script > Execute > Open…. When debugging using Open…, the results is “Five,” as expected and desired.

I can’t figure out a way to combine the two passes into a single list before passing it on. For various reasons having to do with my actual app, handling the input in two separate batches is undesirable.

It is a well known and unfixed AppleScript bug since macOS 10.12.

Late Night Software engineers know that.

So, Script Debugger should add a remediate droplet code, I think.

1 Like

I don’t experience that behaviour on macOS Sequoia 15.1. What macOS version are you running?

There’s never been any guarantee that all items will be passed together, although that certainly used to be the case in practice. The splitting into batches began happening with the introduction of Gatekeeper and file quarantining. As that’s grown more complex, split batches seem to have become more common.

It can be worked around but it requires AppleScriptObjC code, which has side-effects not everyone is happy about.

1 Like

Thanks. “Suck it up” is always better than wasting more time trying to solve the insoluble. :kissing_cat:

—Bryan

Sequoia 15.1.

But thanks.