Starting Applications from a list of aliases

I have a folder in which there are alias files pointing at a group of applications. Double-clicking any of them works. Why doesn’t this script?

tell application "Finder"
	set theDSfolder to alias "my_path_to:Startup Delayed:"
	set lateStartApps to the name of every item of theDSfolder
	repeat with k from 1 to count of lateStartApps
		open item k of lateStartApps
	end repeat
end tell

What it produces instead is this error (names removed):

and yet if I do anything else, like create a new list; “set newlist to newlist & item k of lateStartApps”, it “gets” as expected. I’m assuming that the Finder doesn’t want to start the alias for some reason.

What really bugs me is that this used to work.

Hi,

You have a list of names when you need a reference. Take out the names part.

gl,

Damn. I just had this conversation yesterday in another thread about the differences between “repeat with k from 1 to count of a_List”, then index the list on k, and “repeat with an_Item in a_List” just operating on an_Item. The second form produces a reference that needs “contents of” in some instances (not always coerced to the item). References seem to be the bane of my existence. I didn’t know that names wouldn’t be coerced back to references as required, or more to the point, that telling the Finder to open required a reference to the something rather than its name.

Thanks Kel.

No, this is a different issue than the reference issue from the other thread. As kel correctly tells you, take out the names part meaning change the line:

set lateStartApps to the name of every item of theDSfolder

to

set lateStartApps to every item of theDSfolder

In the original script, you were telling it to open just the name of the item as a string, not the item as a file reference. The issue in the other thread was a problem with a reference to an item in a list as opposed to the contents of the item. This one isn’t a reference issue in the same way, it’s that the contents of the item itself when just limited to the name as string would not produce the desired result. Hope that’s clear (though I doubt it).

Jon

To put it more directly, when the list contains a list of names such as: {“file1.html”, “file2.txt”, “file3.jpeg”} how does the Finder know that, for example, the ‘file1.html’ is the file1.html in ~/Documents/file1.html and not the file1.html in ~/Backup/file1.html, or any other file1.html on disk for that matter.

By using ‘set lateStartApps to every item of theDSfolder’ the list contains something more like {document file “file1.html” of folder “Documents” of folder “username” of folder “Users” of startup disk} which is a completely unambiguous reference to a file that the Finder will happily open.

Got it! Thanks all.

I was thinking that “set lateStartApps to every item of theDSfolder” would set lateStartApps to the contents of those files. I realize that that doesn’t make sense either when the files can be anything.