Finder "alias file" behavior

I have a script that contains this:

	if document file "" of item 1 of (get selection) exists then

And I just (…) noticed that it works even if the selection is a Finder alias, even though

item 1 of (get selection) 

does not have a document file thingy…

So my guess is that the code directly goes to the original item thereof and finds its document file.

I guess that’s the expected behavior, but considering how Applescript is otherwise so picky when it comes to things that are way more trivial than this, I was a bit surprised… Am I tripping on something I should be aware of?

1 Like

That’s expected behaviour. The alias file, I’m assuming, points to a folder, which contains that particular document file, yes ? It is nice when things work well, although we often pass all of the blame onto AppleScript, when often—especially with Finder—it’s the scriptable application that is to blame.

Out of interest, does it still work if you retrieve the selection as an alias list (or selection as {alias, alias list}), so that your reference passed to exists is the document file "..." of... an alias class object rather than an alias file (where the alias file path points to alias file item on the filesystem, not to the original folder) ?

Does that make sense ? It’s a pain that alias has two different meanings in the same context, despite their similar underlying principles, especially since one of them hasn’t upheld its principles for ages.