Delete .rar file if there is a .img file in same folder

Cant get this to work:

Have a little mess after a Hazel misstake with 500 folders.

Is it possible to script following:
Delete all .rar files if there is a .img or .iso or .mp4 file in same folder.

(Or even better, delete all archive-filetypes if there is a diskimage-filetype or movie-filetype in same folder)

Any ideas most appriciated!

Try :

set theFolder to ((choose folder) as text)

tell application "System Events" to tell folder theFolder
	set rarfiles to name of files whose name ends with ".rar"
	set notRarFiles to name of files whose name ends with ".iso" or name ends with ".img" or name ends with ".mp4"
	set i to 0
	repeat with aName in notRarFiles
		set i to i + 1
		set item i of notRarFiles to text 1 thru -5 of aName
	end repeat
	repeat with aRarFile in rarfiles
		if text 1 thru -5 of aRarFile is in notRarFiles then delete file aRarFile
	end repeat
end tell

Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) samedi 16 janvier 2016 19:11:27