I am attempting to change filenames in a directory to the same file type but with incrementing values as the filename. For example let's say I have a directory title "pics" that has the following files:
pic1.png
pic2.png
pic3.png
I want to rename the files to:
1.png
2.png
3.png
Here's the code I tried to run on the file to do this. I set the variable "i" to 0 before running this (I'm using the command prompt, which is why I'm using "%g" instead of "%%g"):
for %g in (*.png) do (
set /a i+=1
ren %g %i%.png
)
What happens is that pic1.png successfully gets changed to 1.png, but then the program tries to rename pic2.png and pic3.png to 1.png. I want them to be renamed to 2.png and 3.png respectively. What am I doing wrong?