Setting name extension droplet

I’m creating a script to add file extensions based on mime types but my script comes back saying

Heres my script:

on open myFile
	set myPath to (POSIX path of myFile)
	set myType to do shell script "file --mime-type -b " & (quoted form of myPath)
	tell application "Finder"
		if myType is "image/jpeg" then set name extension of myFile to "jpg"
	end tell
end open

Can any kind soul tell me where I’m stumbling?


the error message says, the Finder can’t set the name extension, because myFile is a list.
The cause is the open handler, whose parameter is always a list of aliases