Recognize Alias

Hi all.

everytime i use Finder’s Alias with AppleScript (finder’s alias is the real alias, command-m from the menu), the script use always original file instead of the alias.

So, in this case

on open these_items
repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		do shell script "/bin/rm -r " & quoted form of POSIX path of this_item
	end repeat
end open

if i drag an alias on the script, the alias remain alive, but the original file will be deleted.
So, if i want to delete ONLY the alias (file that I dropped)?

I’m study this script (drag an alias):

on open these_items
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set the item_info to the info for this_item
		set alias_var to alias of item_info
		return alias_var -- I suppose that can be true (the file is an alias)
	end repeat
end open

But why alias_var give me false?

Hi, 1802.

That’s exactly what’s supposed to happen when alias files are ‘opened’. They’re links to the original items. If you drag an alias file’s icon to a droplet, or double-click it, it’s the original item that gets opened. Your droplet never sees the alias file itself because the system substitutes the original item during the drop.

Perhaps a folder action would be better suited to your needs?

Another workaround is to get the selected items dropped. e.g.


on open item_list
	tell application "Finder"
		set s to selection
		set n to name of item 1 of s
	end tell
	display dialog n
end open

item_list is a dummy variable. Note that this doesn’t work if items are dragged from rear windows. You would need to add more statements to get the selection of the items dropped to overcome this.

gl,