To be honest, I have no idea what you're trying to do. But, that said, I tried to get your script to run on my system (XP box).
I created a directory,
Z:\TEST
and 2 files in it,
Z:\TEST\BBB.cpp
Z:\TEST\AAA.txt
If found the following script to work well at renaming,
@ECHO OFF
IF...