file cannot be converted into a type string.
Then convert it to a string.
display dialog (name of itemRef) as string
I'd suggest you to use log
instead of display dialog
for debugging purpose.
For instance, log name of itemRef
will return (in your "Events" and "Replies" window):
(name of document file 123.jpg of folder Desktop of folder Saturnix of folder Users of startup disk)
As you can see, this is much more complex than a simple string of test (like "123.jpg"
). This is telling you that name of itemRef
is not returning the actual name of the file itemRef
but a reference to that name. Luckily enough, calling as string
on that reference will return us the actual name of the file.