Generally if you give a script that is not working it always helps to provide what your starting with and
how you want it to look. Are we to assume that the file names may contains spaces as in your example:
Because your output does not only remove the desired string of "[xvid]" but also the prior space.
Assuming we can ignore the space, the following, which builds on catkin's approach, should work:
for name in *.avi
echo mv "$name" "$newname"