I am using a batch file to rename all files in a folder into a numbered list. The code I use is as follow:

```
set /a Index=1

setlocal enabledelayedexpansion

for /f "tokens=*" %%f in ('dir /b') do (
echo %%f
echo !Index!
rename "%%f" "!Index!.*"
set /a Index+=1
pause
)

```

The result of the batch file is

```
G:\Directory A> (
echo
03.jpg
echo 1
rename "
03.jpg" "1.*"
set /a Index+=1
pause
)

03.jpg
1
The filename, directory name, or volume label syntax is incorrect.
Press any key to continue . . .

G:\Directory A> (
echo 04.jpg
echo 1
rename "04.jpg" "1.*"
set /a Index+=1
pause
)
04.jpg
1

```

The first result ALWAYS contains a line break at the beginning of the file name, which causes the RENAME command to fail. Can anyone tell me what is wrong with my code?

---

### UPDATE

There is the folloging auto-run code set up in the Windows registry:

```
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"Autorun"="@chcp 65001>nul & prompt $d$s$s$t$_$p$g & cls"

```