Computing.Net > Forums > Programming > Multiple commands in if statement

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Multiple commands in if statement

Reply to Message Icon

Name: suitto
Date: March 2, 2009 at 17:38:17 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 2, 2009 at 18:15:13 Pacific
Reply:

if not exist zzzz (
dir *.
dir *.bat
)


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

M2


0

Response Number 2
Name: suitto
Date: March 2, 2009 at 18:46:36 Pacific
Reply:

Hi Mech,
Thanks for your quick response and solution.
The placement of the bracket is important.
Lesson learned.
Thanks again.

suitto :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


extracting data from repo... i need ideal



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Multiple commands in if statement

Wildcards in if statement www.computing.net/answers/programming/wildcards-in-if-statement/10769.html

DOS - result of command used in if statement www.computing.net/answers/programming/dos-result-of-command-used-in-if-statement/19202.html

Visual C++: Multiple Columns in list bo www.computing.net/answers/programming/visual-c-multiple-columns-in-list-bo/2730.html