Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: If Exist  (Read 4252 times)

0 Members and 1 Guest are viewing this topic.

Cosma Papouis

  • Guest
If Exist
« on: August 24, 2004, 08:00:15 AM »
Ok so this is a basic Question..

How do I do an if NOT exist in a dos batch file?

I have done if not exist xxxxx

but this does not work.

Helppp!!!!

Thx

2k dummy

  • Guest
Re: If Exist
« Reply #1 on: August 24, 2004, 10:12:46 AM »
You use if exist and if not exist exactly the same way. You must point the command at what you want it check for.

johnwill

  • Guest
Re: If Exist
« Reply #2 on: August 24, 2004, 03:51:55 PM »
If you type IF /? you get:

Performs conditional processing in batch programs.

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command

 NOT               Specifies that Windows XP should carry out
                   the command only if the condition is false.

 ERRORLEVEL number Specifies a true condition if the last program run
                   returned an exit code equal to or greater than the number
                   specified.

 string1==string2  Specifies a true condition if the specified text strings
                   match.

 EXIST filename    Specifies a true condition if the specified filename
                   exists.

 command           Specifies the command to carry out if the condition is
                   met.  Command can be followed by ELSE command which
                   will execute the command after the ELSE keyword if the
                   specified condition is FALSE

The ELSE clause must occur on the same line as the command after the IF.  For
example:

   IF EXIST filename. (
       del filename.
   ) ELSE (
       echo filename. missing.
   )