change the filename with an on open script!

hi!
i tried to change the filename of an item with an on open script like this:

on open theFile
tell application "Finder"
set name of theFile to "anything"
end tell
end open

but it doesn’t work. i hope you can help me.

thanks. nicki.

Hey nicki,
Try this:
on open x
set theFile to x as text
set theFile to theFile as alias
tell application “Finder”
set name of theFile to “George”
end tell
end open

This works on my machine. I am running Mac OS 10.3.5.
Hope it helps.
mike

@ mike
thanks a lot for your help. it works.

nicki

Actually Nicki,
you can skip the step where you set theFile to x as text and just ste theFile to x as alias.
When the on open handler is started, x is a list. All that needs done is to coerce it to an alias.
C-ya!
mike