1.

Solve : cant set values inside a for loop??

Answer»

I make a script like this:

setlocal
setlocal enabledelayedexpansion
set /A j=0
for /L %%i in (501,1,600) do (
set /A j=%%i-500
echo %j%
)

but I always get echo 0.........
Why?
try this instead

setlocal
setlocal enabledelayedexpansion
set /A j=0
for /l %%i in (501,1,600) do (
CALL set /a j=%%i-500
call echo %%j%%
)
Thanks a LOT. That WORKS.

Basically, I just want to rename my files and try to make it general and easy.
very simple task, convert files names:

file501.xml
file502.xml
file503.xml
....
file599.xml

TO:
newfile1.xml //from file501.xml
newfile2.xml //from file502.xml
newfile3.xml .....
....
newfile99.xml //from file599.xml


Tried several SCRIPTS, none of them works....

Thanks a lot if you can help. I am pretty new for MS-DOS.

or you could use !j! since you have delayed expansion enabled. yes. Thanks.

just new here, need to read some basic stuffs first to move on....


Thanks.check help for set and for commands good reading

set /? > c:\setcmd.txt
for /? > c:\forcmd.txt

and read them



Discussion

No Comment Found