I need help with this batch file I’m working on,
Basically everytime it does a task it should plus the variable %number% by one which works fine and all and then repeat over again doing a different task until its completed.
This is the code which it uses to repeat
I need a way of settings basically:
set svn=%svn%%number%
set svnlink=%svnlink%%number%
set svnfolder=%svnfolder%%number%
Instead I am using:
if %number%==1 (
set svn=%svn1%
set svnlink=%svnlink1%
set svnfolder=%svnfolder1%)
if %number%==2 (
set svn=%svn2%
set svnlink=%svnlink2%
set svnfolder=%svnfolder2%)
if %number%==3 (
set svn=%svn3%
set svnlink=%svnlink3%
set svnfolder=%svnfolder3%)
Which i really need to shorten as this goes up to number 20+
Is this possible? If you could help me, Thanks!
Use a temporary batch file. This might not be elegant, but it works:
But beware: It can get quite difficult to find out the number and order of
%‘s to use here. In the example,%%svn%number%%%is transformed to%svn[actual value X of variable number]%and this is transformed to the actual value ofsvnXinside ofa.bat.So your actual code should be like this:
This can also be used as a subroutine: