Solved Multiple commands in if statement

March 2, 2009 at 17:38:17
Specs: Windows XP
Hi,
Is it possible to have 2 or more commands in the "do something" portion of the if statement? The if statement goes

if (condition) command

Is it possible to have it like

if (condition) (execute command1 follow by command2)

e.g.
if not exist "input.txt" (echo "File don't exists" goto :EOF)
Because I want to inform the user first and then exit the batch.

If I put the code as
if not exist "input.txt" (echo "File don't exists")
goto :EOF
The goto :EOF gets executed even the input file exists.

Please advise.Thank you


See More: Multiple commands in if statement

Report •


#1
March 2, 2009 at 18:15:13
✔ Best Answer
if not exist zzzz (
dir *.
dir *.bat
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
March 2, 2009 at 18:46:36
Hi Mech,
Thanks for your quick response and solution.
The placement of the bracket is important.
Lesson learned.
Thanks again.

suitto :)


Report •

Related Solutions


Ask Question