for loop error

December 29, 2010 at 10:10:35
Specs: Windows XP
I can not get filling the place holder to work right.(from {start here} to {end here})
I tried the SetLocal EnableDelayedExpansion to and it did not work

thanks for all your help

::set file count
set ___file=%~dp0dbook-count.txt

::count in and out
set /p __c=<%___file%
set /a __c+=100
if not exist %___file% (set __c=1)
echo %__c%>%___file%

::nameing set up

set _name=%~n1
set _name=%_name:*_-_=%
set _n=%_name:*_-_=%
echo %_n%

::filling place holders {start here}

set _tr=%__c%
set base__=10
set __answer=

for /l %%A in (1,1,6) do (
set a1__=%_tr_%/%base__%
set a2__=%_tr_%-(%a1__%*%base__%)
set __answer=%a2__%%__answer%
set _tr_=%a1__%

{end here}
set __out=%~dp0\in\book-%__answer%
echo .%_n%>%1\%_n%.txt
move %1 %__out%

See More: for loop error

Report •

December 30, 2010 at 03:46:59
I did not enter into the meaning of your code, but I notice two mistakes:

- After enabling the Dynamic Expansion you have to mark the environment variables inside the FOR loop with ! instead of usual % (e.g. set _tr_=!a1__!)

- To perform math you have to code SET /A (e.g. set /A a1__=!_tr_!/!base__!)

And another hint: to avoid unwanted surprises (if you are not a batch super-Guru) code SETLOCAL at the beginning of your script and never issue ENDLOCAL.

Report •

January 4, 2011 at 11:38:57
"set _name=%_name:*_-_=%"

Why dont you set easy variable names?

Happy is ONE who says I am an OttoMAN.

Report •
Related Solutions

Ask Question