[I have searched for a similar question but I did not find what I was looking for, so I am posting a new one.]
I want in my .bat file to SET a directory in a variable and I want to find all the files inside this directory (which all start with the same name) and rename them according to this pattern.
e.g file_location1.wml -> file1.wml
file_location2.wml -> file2.wml
file_location3.wml -> file3.wml
Till now I am trying something like this:
SET counter=1
FOR /R %%f IN (C:\Documents\testFiles\*.*) DO (
FOR /F "DELIMS=_ TOKENS=1,*" %%m IN ("%%~nxf") DO (
REN "%%f" "%%m%counter%"
SET counter=counter+1
}
}
It does not work. What am I doing wrong? I specify that i want to iterate over the files and rename each one with the first token + the counter's value.