1.

Solve : set num1 = %num1% + 1?

Answer»

yeah this is SOMETHING I've been thinking about, I might not find a GOOD use for it but I like to try this KINDA stuff out in case I get any ideas...

so I'm making text documents and naming them sequentially...
this program can be exited and when restarted would pick up basically where it left off because it checks if the files are there. even if some are missing here and there it would STILL remake them...

heres the code im trying to use:
Code: [Select]set NUM1=1
:start
if exist %num1%.txt set num1 = %num1% + 1
echo hello>%num1%.txt
goto startIf you're using XP - at the COMMAND Prompt enter SET/? and have a look at the SET/A switch.

Arithmetic gets tricky when using environment variables:

Code: [Select]set num1=1
:start
if exist %num1%.txt call set /a num1=%%num1%%+1
echo hello>%num1%.txt
goto start



thanx, works great



Discussion

No Comment Found