Getting file name from alias

Sometimes the simplest task won’t work: :frowning:

on adding folder items to this_folder after receiving added_items
	
	repeat with theFile in added_items
		set filename to name of theFile <--generates an error!
		.....

My reasoning is:
added_items is a list of aliases
Therefore: theFile is an alias (alias “Macintosh HD:Users:vml:Desktop:test.doc”)
Therefore: I should be able to get the name of the alias! (test.doc)

I worked around the problem like this:

	set AppleScript's text item delimiters to {":"}
	
	repeat with theFile in added_items
		set filename to theFile as string
		set filename to the last text item of filestring

It works, but I’m sure it could be done in a better way! How?

Hello again Vince(nt)

You can do this many different ways.

on adding folder items to this_folder after receiving added_items
	
	repeat with theFile in added_items
		set myInfo to info for file  theFile
		set theFileName to name of myinfo

		.....

you can also do is this way

on adding folder items to this_folder after receiving added_items
	
	repeat with theFile in added_items
		tell application "Finder"
		set thefileName to name of theFile
		end tell

		.....

have fun

bastiaan

Off course! I forgot the tell “Finder” part again!!!
(Second time I step into that trap!)

Thanks again!