# batch file help



## okysP-Panda (Feb 24, 2004)

What I am trying to do is create a sript that will take an input value in the form of a number, and then copy "1.exe" with the input number as the name. Then I want it to subtract one from the input number and repeat the process, creating many #.exe files, all identical except for the name. Finally, I want to be able to stop the process when the file 0.exe is created. 
The following is what I have come up with so far. I am getting an error when it reaches "if /i %abc% LSS %1 goto END" the process stops and says 0 was unexpected at this time.
I need this file to work for Windows 2000, but would like it to work with other versions of win too.

set [[/a [%1 GTR 999]] [/p [abc=%1]] goto ER2]
set [[/a [%1 LSS 1]] [/p [abc=%1]] goto ER2] 
:N2
copy 1.exe c:\winnt\%abc%.exe
set /a %abc% "-=" 1
set [[/a [%1 GTR 1]] [/p [%abc%-=1]] goto N2]
if /i %abc% LSS %1 goto END
goto N2
:ER2
echo You must specify a number >0 and <1000, as in "1" or "999"
:END

If anyone could show me what I am doing wrong, or possibly show me an easier way to do this, it would be much appreciated.


----------



## dtech10 (Jan 31, 2003)

Hi okysP-Panda

Try this for 2000/NT/XP

Win9x O/S is not as easy without third path utility programs to do the arithmetric.
But I'll see what I can come up with if you want.

@echo off
set Msg=Enter number between ^0 and ^1000
:begin
set Count=
set /p Num=Enter Number 1 to 999:
if "%Num%"=="" goto end
if %Num% lss 1 (
echo %msg%
goto begin
) 
if %Num% gtr 999 (
echo %msg% 
goto begin
) 

:loop
copy 1.exe c:\winnt\%Num%.exe > nul
set /a Num=%Num%-1
if %Num% gtr -1 goto loop
echo Done!
:end


----------

