Apologies if duplicate, but no other answers so far have helped.

All I'm trying to do is loop through the files in a folder, and rename the last part of the file/extension.

Simply put - there could be 1-90 files, [filename]\_01 - [filename]\_90, and each day (via windows event scheduler) the number has to increment by one.

Nothing I do seems to achieve this.

The files are also meant to behave slightly differently when they hit certain milestones (30-60-90) but this I believe should already work if the variables update properly.

I have tried so many possible combinations of variable addressing (!variable!/%variable%/etc.) and while I can enter the loop, it does not repeat, nor update the variable number for the end of the files.

```
SetLocal EnableDelayedExpansion
set cnt=0
for %%A in (*) do set /a cnt+=1
set /A fileNumber = %cnt%-1
set /A newFileNumber = %cnt%
echo %fileNumber%
echo %newFileNumber%
for /l %%F in (%fileNumber%,1,1) do (
    if %newFileNumber%==90 (
        ren "*_%fileNumber%.don" "*_%newFileNumber%.csv"
        )
    if %newFileNumber%==60 (
        ren "*_%fileNumber%.don" "*_%newFileNumber%.csv"
        )
    if %newFileNumber%==60 (
        "ren *_%fileNumber%.don" "*_%newFileNumber%.csv"
        )
    ren "*_%fileNumber%.don" "*_%newFileNumber%.don"
    set fileNumber=%fileNumber%-1
    set newFileNumber=%newFileNumber%-1
    )

```

This should simply update all the files in the directory to increment by 1 in the file name. If anyone can point out where I'm going wrong I would really appreciate it.