I don't like string substitution syntax, it looks obscure, instead I would use basename in this way:
mv "$i" "$(basename "$i" .avi).mkv"
from .avi to .mkv, real simple and readable, this is what I always use.
Now, of course, I don't use this to batch rename things, I use rename. Instead I use this when converting formats with ffmpeg.