The problem is, that the renamed files can be found and renamed a second time.
Add an ECHO rename "%%j" "[nilesh.uk.to]-%%~nxj"
to your code and you will see something like
rename "C:\temp\bracket\demo1.txt" "[nilesh.uk.to]-demo1.txt" rename "C:\temp\bracket\demo2.txt" "[nilesh.uk.to]-demo2.txt" rename "C:\temp\bracket\demo3.txt" "[nilesh.uk.to]-demo3.txt" rename "C:\temp\bracket[nilesh.uk.to]-demo1.txt" "[nilesh.uk.to]-[nilesh.uk.to]-demo1.txt"
So you need to force the FOR
loop to take each file only once.
You could change it to
for /F "delims=" %%j in ('dir /s /b *.html') do (
....
This works, as the dir /s /b *.html
will be completly executed before the first rename command will be executed.