ÃOMMAND: IF ÓYNTAX: IF EXIST PATTERN COMMAND IF STRING1 = STRING2 COMMAND IF ERRORLEVEL N COMMAND ÓEE ÁLSO: ÂÁÔÃÈ, ÂÅÇÉÎ, ÌÏÏÐ, ÇÏÔÏ, ÇÅÔËÅÙ, ; IF IS USED TO CONTROL THE ACTION TAKEN INSIDE BATCH FILES. ÃOMMAND CAN BE A ÂÁÓÉÃ COMMAND OR A ÃÓ-ÄÏÓ COMMAND. ÏNLY A FEW ÃÓ-ÄÏÓ COMMANDS RETURN ERRORLEVELS THAT MAKE ANY SENSE. ÕSUALLY THEY DON'T. ÉN GENERAL, THOUGH, AN ERRORLEVEL OF ZERO MEANS THE COMMAND DID WHAT YOU EXPECTED IT TO DO AND ANY OTHER VALUE MEANS THAT IT FAILED FOR ONE REASON OR ANOTHER. IF EXIST PATTERN COMMAND ÔHIS EXECUTES COMMAND ONLY IF THE FIRST FILE MATCHING PATTERN EXISTS. IF STRING1 = STRING2 COMMAND ÔHIS EXECUTES COMMAND ONLY IF THE TWO STRINGS ARE THE SAME. IF ERRORLEVEL N COMMAND ÔHIS EXECUTES COMMAND ONLY IF THE LAST COMMAND RETURNED AN ERRORLEVEL OF N. ÆOR EXAMPLE, HERE IS A BATCH FILE TO IMPROVE UPON THE DEL COMMAND. ÌETS SAY WE CALL THIS "ERASE" IF "%1" = " " GOTO USAGE IF "%2" = "IFON" GOTO DELIF DEL %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO DONE :DELIF IF "%3" = " " GOTO USAGE IF EXIST %3%1 DEL %1 GOTO DONE :USAGE ECHO USAGE %0 FILENAME [IFON D:] :DONE ; ÓO THAT INVOKING IT WITH ERASE NAME ×OULD BE THE SAME AS DEL NAME ÂUT INVOKING IT WITH ERASE NAME IFON B: ×OULD ONLY DELETE THE FILE IF A FILE WITH THE SAME NAME EXISTED ON DRIVE B: ÏR HERE IS A BATCH FILE TO ASSEMBLE AND REINSTALL SOME PROGRAM. ÓUPPOSE WE CALL IT "ASSM", THEN INVOKE IT WITH -> ASSM NAME ASM %1.ASM %1 IF NOT ERRORLEVEL 0 GOTO ERROR REMOVE %1 INSTALL %1 GOTO DONE :ERROR ECHO ÁSSEMBLY ERROR. :DONE ;