Renaming filename with counter in windows batch

Viewed 2637

I want to change files from 1-example.txt to 200-example.txt (just change start number) with code below:

@Echo off

setlocal ENABLEDELAYEDEXPANSION
SET /a counter=200

for /F %%i in ('dir /b/a-d *.txt') do ( 
    for /F "usebackq tokens=1,* delims=-" %%c in ('%%i') do (
        SET filename=%%i
        :: Dunno how to fix
        echo !filename:%%c=%counter%!
        :: ren %%i %%newfilename
    )
    SET /a counter+=1
)

but it doesn't work, it shows 200 all the time. When I change %counter% to !counter! it shows nothing. How fix the counter?

1 Answers
Related