REN AB* ABX*
Working
The TargetMask is processed against the source name strictly from left to right with no back-tracking.
Let the character c represents all characters except '*','.' and ' ' (space).
In the TargetMask c Advances the position within the source name as long as the next character is not . and appends c to the target name.
'*' At end of sourceMask - Appends all remaining characters from source to the target. If already at the end of source, then does nothing.
Complete reading source: dbenham's answer to rename command
Explanation
In your case first A of TargetMask is matched with A of SourceMask.
B of TargetMask is matched with B of SourceMask.
X of TargetMask is matched with * of SourceMask and *(position 3 of SourceMask which is C) is replaced by X.
Finally * of TargetMask is matched with * of SourceMask which is {DE}(as position C has already been replaced by X)
Solution Step by Step
You can do this by following these steps:(Assuming the file has an extension of .txt ie. initial file name is ABCDE.txt)
REN AB* " "*
NOTE: there are two spaces inside quotes.
In the command above I am replacing first two chars by two blank space chars. Status of file name after executing this command:' CDE.txt' two blank spaces in the beginning of the name.
FOR %v IN (" "*) DO REN "%v" %v.X
NOTE: there are two spaces inside quotes.
In the above command I have removed the initial two spaces and renamed the file with .X extension. Status of file name after executing this command: 'CDE.txt.X'
FOR %v IN (*.X) DO REN %v ABX%v
In the above command I have prefixed the file with ABX.Status of file name after executing this command: 'ABXCDE.txt.X'
FOR %v IN (*.X) DO REN %v *.txt
By using above command I am renaming 'ABXCDE.txt.X' to 'ABXCDE.txt'.
In depth Reading about tricks of ren: http://www.lagmonster.org/docs/DOS7/z-ren1.html