BATCH FILE TIPS AND UTILITIES The Fifth in a series by Mitchell A. Hoselton EYAWTKATICBWATA That is, "Everything You Always Wanted To Know About The IF Command, But Were Afraid To Ask." Two months ago I introduced the IF ==, IF NOT ==, IF ERRORLEVEL and IF NOT ERRORLEVEL commands. Last month I included more batch file examples of the IF command. The IF command only works within batch files. It does not work when typed at the DOS prompt. This month I will attempt a complete introduction to the IF command. First, a little nomenclature is in order. It is customary, when discussing syntax, to write the NOT in square brackets. The brackets indicate that it is an optional parameter. A compact description of the three types of IF test (six different tests) appears on the following three lines. IF [NOT] ERRORLEVEL test_value command_to_execute [command_parameters] IF [NOT] string1==string2 command_to_execute [command_parameters] IF [NOT] EXIST filename command_to_execute [command_parameters] The command_to_execute can be any legal DOS or application name. It can include path information, if the command_to_execute accepts path information. It can include command line parameters, if the command_to_execute requires any command line parameters. Command_to_execute can even be another batch file. The command_to_execute will only execute if the preceding IF test is true. The first requirement for using the IF command is developing a clear understanding of the nature of the six different IF tests. Batch file programmers must thoroughly understand the criteria that determine when an IF test is true. The remainder of this article examines each of the three types of IF test and their uses in turn. ERRORLEVEL TESTS There is nothing that the user can do to set or change the ERRORLEVEL. The ERRORLEVEL is only a parameter for the IF test. ERRORLEVEL tells the IF command to test the current value of the exit code stored in COMMAND.COM. The user can affect the value of the exit code only by running a program that sets a new exit code. COMMAND.COM has an internal register (one byte long) where it stores the exit code. After running any external DOS command or non-DOS application program, COMMAND.COM stores an exit code in this register. The external DOS commands and applications programs may tell COMMAND.COM to set the exit code to any value from 0 through 255. Internal MS-DOS commands and the commands in the Batch File Control Language do not set or change the exit code. Most external DOS commands and application programs do not set a specific exit code. If a program does not specify any other value, then COMMAND.COM resets the exit code to zero. COMMAND.COM can only store one value of the exit code at any time. When it sets or resets the exit code, it automatically overwrites the previous value. COMMAND.COM sets the exit code each time it runs a program. Testing the exit code using the ERRORLEVEL parameter in an IF command does not reset the exit code. Therefore, a series of IF ERRORLEVEL tests can test the same exit code as many times as necessary. A) The IF ERRORLEVEL test_value test is true, whenever the exit code is greater than or equal to test_value. Consider a series of test_values. If the current value of the exit code is 4, than a tabulation of the results of a series of IF ERRORLEVEL test_value tests, for different test_values, will look like this. Result of test Test Performed when exit code=4 ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ IF ERRORLEVEL 7 false IF ERRORLEVEL 6 false IF ERRORLEVEL 5 false IF ERRORLEVEL 4 true IF ERRORLEVEL 3 true IF ERRORLEVEL 2 true By running these tests in a descending cascade, batch files find the first true result when test_value and the exit code are equal. If a batch file runs only the last test, it can determine that the exit code is greater than or equal to two (2). It has no way of determining that the exit code is actually four (4). The IF ERRORLEVEL 0 test is always true, because zero is less than or equal to every possible value of the exit code. The command_to_execute does not execute when the test result is false. To execute a specific command if and only if the exit code is 4, requires testing the highest exit code first. The descending cascade of consecutive ERRORLEVEL tests works for this purpose. The batch file must use tests where the test_value decreases in integer steps on successive lines. Assuming only values from one (1) through seven (7) need testing, here is an example based on the table above. IF ERRORLEVEL 7 GOTO do_7 IF ERRORLEVEL 6 GOTO do_6 IF ERRORLEVEL 5 GOTO do_5 IF ERRORLEVEL 4 GOTO do_4 IF ERRORLEVEL 3 GOTO do_3 IF ERRORLEVEL 2 GOTO do_2 When the exit code is one (1), none of the GOTO commands executes. The line after the IF ERRORLEVEL 2 test executes, instead. Use this arrangement to be sure that the first true test occurs on the line that has a test_value matching the value of the exit code. The results of the remaining tests would have produced true results, too, but those tests will not execute. The first true test executes a GOTO sending the execution pointer to another location in the batch file. The GOTO command prevents the remaining tests from executing. B) The IF NOT ERRORLEVEL test_value test is true whenever the exit code is less than test_value. Remember, the opposite of "greater than or equal to" is "less than." Consider a descending cascade of test_values. If the value of the exit code is 4, again, than a tabulation of the results of the IF NOT ERRORLEVEL test_value tests, for a series of test_values, will look like this. Result of test Test Performed when exit code=4 ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ IF NOT ERRORLEVEL 7 true IF NOT ERRORLEVEL 6 true IF NOT ERRORLEVEL 5 true IF NOT ERRORLEVEL 4 false IF NOT ERRORLEVEL 3 false IF NOT ERRORLEVEL 2 false These results are the exact opposites of those obtained from the IF ERRORLEVEL test_value test. The effect of the NOT is simply to change true results to false and false results to true. A descending cascade of IF NOT ERRORLEVEL test_value tests will give the first false result when the test_value is equal to the value of the exit code. There is a fairly elegant use for the IF NOT ERRORLEVEL test. It is sometimes quite useful. This involves using two IF tests together on the same line (called "nested" IF commands). The general form of this test can bracket the exit code in a range. Its ultimate use is to set the range so narrowly that the exit code can only have one particular value and still produce a true result. The general form looks like the following. IF ERRORLEVEL x IF NOT ERRORLEVEL y command_to_execute [command_parameters] The value of y must be greater than x. The test produces a true result and the command will execute whenever the exit code has a value between x and y-1, inclusive. If x = y-1, then the upper and lower limits of the exit code range are the same value, namely x. Therefore, the result of the combined test is true and the command executes if and only if the exit code equals x. This programming tip allows batch files to test values of the exit code in any convenient order. The command_to_execute will execute if the exit code is exactly equal to the first test_value. If an application issues an exit code that only takes on three values, 0, 1 and 2, say, they can be tested, as follows. IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 GOTO do_1 IF ERRORLEVEL 0 IF NOT ERRORLEVEL 1 GOTO do_0 IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 GOTO do_2 The order of these three lines is completely arbitrary. (Do you know what is wrong with the middle test above? It will work as advertised but it could be shortened.) The IF ERRORLEVEL test_value test in each line is true if its test_value is less than or equal to the exit code. The IF NOT ERRORLEVEL test_value test only executes when the first test is true. The IF NOT ERRORLEVEL test_value test is true only if its test_value is greater than the exit code. The command_to_execute executes only if both tests are true. Reading the first line, for example, the two assertions are: a) 1 is less than or equal to the exit code; b) 2 is greater than the exit code. If true, part a) says possible values of the exit code are 1,2,3,4,..., etc. If true, part b) says the exit code is less than 2, namely 0 or 1. The only number appearing in both lists is one (1). Therefore, both tests are true and the command_to_execute executes if and only if the exit code equals one (1). It is the only exit code value that passes both IF tests. The exit code provides a method of returning data from an executable program back to a batch file. It complements the batch file's ability to store string variables in the DOS environment for application programs to use. (Usually, application programs do not create or alter environment variables. BOOTCON is the only exception that comes immediately to mind.) The DOS environment provides almost limitless possibilities for passing information. The exit codes, on the other hand, offer only 256 possibilities. Sometimes that limitation is an advantage. It is possible to test for each one of the 256 possible exit codes. Such a test takes only a fraction of a second. We will examine several batch files which can perform such a test in a future article in this series. STRING COMPARISON TESTS String comparison tests using the IF command are always case sensitive. This is a major exception to DOS's usual practice of ignoring case altogether. The strings "ABCDEF" and "aBcDeF" are not the same in a case sensitive comparison. They are the same when case is not a factor. Strings can be of two types; literal strings and string variables. String variables come from three separate sources; the DOS environment, batch file replaceable parameters, and defined string sets in a FOR IN DO command. DOS uses one or two percent signs (%) to make the different types of string variables distinguishable. The string without a percent sign in front of it, on the other hand, is a literal string. Literal strings and string variables can be concatenated simply by typing them consecutively on the same line. When using the IF [NOT] string1==string2 test, it is not necessary to surround each string with quotation marks. Nevertheless, all the examples presented in this series will contain quotation marks. This is a programming tip which eliminates problems that occur when using string variables. Specifically, it avoids problems that can arise when testing an undefined string variable. If a string variable happens to be undefined, the IF command will find itself comparing a null string against a non-null string. This can produce unexpected results. To prevent the appearance of null strings in these tests, many have recommended adding matching characters to the strings on both sides of the comparison. As long as the extra quotation marks on both sides of the double equal sign (==) balance each other, they will not have any effect on the results of the test. The quotation marks require a little extra typing, but they work well and do not interfere with the readability of the command. If a string variable enclosed in quotes is undefined, the combined string reduces to a pair of quotation marks, ie "", rather than to a null string. It works equally well to add leading and trailing letters, numbers or other characters to each side. Over the years, Ronny Richardson, as in his book on "MS-DOS Batch File Programming," 2nd edition, published by Windcrest Books, has recommended the use of slashes (/). He recommends using the slash only when testing explicitly for null strings. This works well and avoids typing the extra quotation marks, too. The MS-DOS 5.0 "User's Guide and Reference" published by Microsoft Corporation now recommends the use of quotation marks in the section titled "Controlling Program Flow," pages 235-236. The choice is almost arbitrary. This series consistently uses the enclosing quotation marks. Literal strings are just exactly what they appear to be. The following string is a simple example. "this is a test string" It consists of leading and trailing quotation marks and all the characters, including the spaces, that appear between them. Literal strings do not stand for anything else. There is not much point in comparing literal strings with each other. (The batch file author knows while writing the command if the two literal strings are equal. There is no point in testing them.) More commonly, comparisons are between one literal string and one string variable or between two string variables. With these points in mind, change the general form of the string comparison test slightly to read as follows. IF [NOT] "string1"=="string2" command_to_execute [command_parameters] String1 and string2 can each be literal strings or string variables. The double equal sign (==) is best thought of as requiring the same or identical strings. It's usually called the "IF-equal" test, but try to think of it as the "IF-same-string" test. The IF == test is true if the string values on both sides of the == sign are letter by letter and case by case the same. Obviously, the two strings must be the same length. The corresponding IF NOT == test is true whenever the string values are not the same. The remainder of this section will examine the sources and uses of the three types of string variables. A) String comparisons involving DOS environment variables were introduced in the third article in this series. The DOS environment variable name must always sit between two percent signs (%), eg %BOOTCON%, when using it in a batch file. In this form it acts as a stand-in for the current string value assigned to the variable. Before it does the actual comparison, COMMAND.COM temporarily substitutes the string variable's value into the slot occupied by the string variable's name and its delimiting percent signs. Here is how it works. Assume the DOS environment variable BOOTCON has the value C. What happens when COMMAND.COM finds a test that looks like this? IF "%BOOTCON%"=="C" GOTO do_c It temporarily substitutes the value stored in the BOOTCON variable so that the test reads like this. IF "C"=="C" GOTO do_c COMMAND.COM substitutes the variable's value for the variable name and compares the value with the other string. During the test the strings are the same and the GOTO command executes. When the DOS environment variable BOOTCON has the value B, COMMAND.COM changes the test to read like this. IF "B"=="C" GOTO do_c In this case the strings are not the same and the GOTO command does not execute. The next line of the batch file executes instead. On the other hand, the following command produces a different result. IF NOT "%BOOTCON%"=="C" GOTO not_c It tests to see if the strings are not the same. When the BOOTCON variable has the value C, the GOTO does not execute. When BOOTCON has the value B or any value except C, the GOTO does execute. Testing for both upper and lower case values requires using two consecutive IF commands, like this. IF "%BOOTCON%"=="C" do_c IF "%BOOTCON%"=="c" do_c DOS always capitalizes the name of the environment variable when it stores it in the environment. The variable name between the per cent signs does not have to be capialized. The value assigned to the variable will be stored in the environment as upper case, lower case or mixed case, depending on how it was originally entered. Capitalizing the variable name whenever it appears in a batch file is a good habit, but not a requirement. The case of the variable value is important, but the case of the variable name is not important to DOS. B) This section introduces string comparisons involving batch file replaceable parameters for the first time in this series. These are always named using a single digit number with a leading percent sign. That distinguishes them from the DOS environment variables that have both leading and trailing percent signs. The replaceable parameters are assigned values based on the order in which string values appear on the command line. Each string on the command line must be separated from the other strings on that same command line by a delimiter. The space is the most common delimiter. Other legal DOS delimiters are the semicolon (;), comma (,), and equal sign (=). The first replaceable parameter is %0. Its string value is the batch file's name. The second replaceable parameter is %1. It receives as its value the first string on the command line following the batch file name. The remaining parameters in order are %2, %3,..., %8, %9. The values assigned to these replaceable parameters are the consecutive strings added to the rest of the command line. When more that ten parameter values appear on the command line, they are not assigned names until a SHIFT command executes in the batch file. When specifying less than ten parameter values on the command line, the unused replaceable parameters acquire a null value. A hypothetical batch file named TEST_BAT.BAT might execute from the command line with the following syntax. TEST_BAT param_1 param_2 param_3 where param_1 might be a drive letter, param_2 might be a particular subdirectory on the drive and param_3 might be an application stored in that directory. The job of TEST_BAT.BAT is to switch to the drive specified by param_1, change to the directory specified by param_2 and then execute the application program specified by param_3. This would be a general purpose batch file used to run applications by typing a single line at the DOS prompt. Inside TEST_BAT.BAT, the replaceable parameter %1 represents param_1. Similarly, the replaceable parameters %2 and %3, respectively, represent param_2 and param_3. Specific examples might help. Assume the following command is entered at the DOS prompt. TEST_BAT C: \lotus 123 Somewhere in the batch file, the following line might appear. IF "%3"=="" GOTO error_1 This is a test for a null string at the fourth command line position. If the %3 parameter has a null value, the batch file needs more facts to do its job. The :error_1 label presumably heads a section of code that prints an error message on the screen. The error message should remind users about the parameters to include and the order in which they should appear on the command line. To prevent TEST_BAT.BAT from working with floppy disks, the following sequence of tests might be performed. IF "%1"=="B:" GOTO error_2 IF "%1"=="b:" GOTO error_2 IF "%1"=="A:" GOTO error_2 IF "%1"=="a:" GOTO error_2 The :error_2 label presumably heads a section of code that prints a message on the screen reminding users not to use TEST_BAT.BAT with the floppy drives. When testing command line input like this, checking for both upper and lower case versions sometimes gets a little tedious . Additional tests to determine if the drive name includes the colon might also be in order. TEST_BAT.BAT should verify that the listed drive and directory exist. Use ISDEV and the IF EXIST test for those tests. C) String variables passed from the FOR IN DO command can, among other things, speed up the process of sorting through the upper and lower case comparisons. This is the first look at the FOR IN DO command in this series. The syntax of the FOR IN DO command is as follows. FOR %%variable IN (set) DO command_to_execute [command_parameters] Unlike IF commands, the FOR IN DO commands cannot be nested. There is a way to solve that problem, too, but it will have to wait for another day. FOR IN DO is one of the batch file commands that also works from the command line. When using it from the command line, the variable (which is always a single letter) uses only one leading percent sign (%). The batch file replaceable parameters also have a single leading percent sign. There should not be any confusion between them, because one usage applies only to batch files and the other only to command line execution. Still, to keep it simple and avoid any possible confusion, DOS requires that the variable used in FOR IN DO commands always be a single letter. DOS does not permit using single digit numbers as the FOR IN DO variable. Inside a single FOR IN DO command, programmers must use the same letter (including the case) each time the variable name appears. All the FOR IN DO commands in a single batch file can use the same variable name or each can use a different variable. Here is a demonstration using the FOR IN DO command in combination with the IF command. It shows how their combination can replace the four IF statements given at the end of the last subsection. It also covers the situation where the colon was omitted. Here is how it looks. FOR %%D IN (a: A: b: B: a A b B) DO IF "%1"=="%%D" GOTO error_2 A delimiter separates each member of the set from the others. In this example, the delimiter is the space (ASCII 032 or 20h). The space is the most common delimiter. Other legitimate delimiters are the semicolon (;), comma (,) and equal sign (=). All of these act as delimiters between the parameters entered after the batch file name on the command line as well. That %1, remember, is the replaceable parameter standing in for the disk drive name typed after TEST_BAT at the DOS prompt. The FOR IN DO command systematically replaces the %%D appearing in the IF test with each member of the set listed in parenthesis. (Note that %%d is not the same as %%D; this is another instance where DOS is sensitive to case.) The use of the GOTO inside a FOR IN DO command evokes a special response from DOS. DOS always processes every member of the set before it will move the execution pointer to another position in the same batch file. Therefore, the FOR IN DO and IF commands process all the values in the set before processing the GOTO command. The first member of the set to produce a true IF test, only creates a pending GOTO command. If a later member of the set also produces a true IF test, it creates a pending GOTO that overwrites the first one. This continues until it processes every member of the set. Only then is the pending GOTO finally processed. There can only be one pending GOTO. That is the GOTO command generated by the last member of the set to produce a true IF test. If none of the tests is true, the FOR IN DO command does not create a pending GOTO. The next line of the batch file executes instead. DOS's treatment of the GOTO command contrasts with DOS's ability to process the following command. Here the FOR IN DO command executes three separate batch file subroutines, called SUB1.BAT, SUB2.BAT and SUB3.BAT. FOR %%G IN (1 2 3) DO IF EXIST sub%%G.bat CALL sub%%G Execution of the subroutines does not involve moving the execution pointer inside the calling batch file. Therefore, DOS has no trouble executing the CALL for each member of the set that generates a true test. DOS does not seem to create pending CALLs. It appears to execute each CALL command immediately. If DOS can create multiple pending CALLs, there must be some limit to how many pending CALLS it can manage. If such a limit exists, I have not been able to discover what it is. A single FOR IN DO command with 47 CALLs in it executes all 47 of them without a hitch. FILE EXISTENCE TESTS The file existence test is the third and final version of the IF test. It is making its first appearance in this series. DOS versions before 3.0 did not support the use of path information with the filename in this test. In later versions, including DOS 5.0, the use of path information is fully implemented. Most DOS commands have supported the inclusion of path information since version 2.1. Now the IF EXIST test does, too. The general form of the file existence tests is as follows. IF [NOT] EXIST [drv:[path]\]filename command_to_execute [command_parameters] In its simplest form, this test returns a true answer if the file specified by filename does [NOT] exist in the specified directory. When no drive and path are specified, it only checks the current directory. The IF EXIST test does not look for files on the DOS PATH. Here are a couple examples. This first one checks for the existence of any file named 123.COM in the current directory and moves the execution pointer to the line following the label :lotus if 123.COM does exist. IF EXIST 123.COM GOTO lotus The second test changes the execution pointer to the line following the label :lotus, if a 123.COM file exists in the lotus directory on drive D:. IF EXIST D:\lotus\123.COM GOTO lotus Testing for the existence of a file might be appropriate to be sure that files you want to copy to another location are in the source directory. It might make sense to find out if the files are already in the target directory, too. Some simple anticipated uses for the IF EXIST test will not work, unfortunately. The wildcard characters, * and ?, can stand for any string and any character, respectively. The TYPE command does not accept wildcard characters, however. Therefore, the following command will not type all the batch files in the C:\BATCH directory on the printer. IF EXIST c:\batch\*.bat TYPE c:\batch\*.bat >PRN (Does not work) On the other hand, it is easy to type a single file on the printer, as follows. IF EXIST c:\batch\*.bat TYPE c:\batch\testing.bat >PRN The *.bat means "any batch file." The redirection symbol ">" indicates redirection of the output to a device or file. In this case it redirects the output to PRN, the default printer. Unless a command specifies another destination, DOS always directs output to the console display device. (See the introduction to redirection and piping in an upcoming article in this series.) The IF EXIST command understands the use of both wildcards and redirection. TYPE only understands the redirection. DOS is clearly not fully integrated with itself. Some of the older commands, like TYPE, are starting to show their age. DOS has a partial answer to the inadequacies of the TYPE command. Ronny Richardson pointed this out in "MS-DOS Batch File Programming" 2nd Edition, on page 409. The TYPE command will work with defined string sets passed from the FOR IN DO command. The FOR IN DO command, in turn, understands wildcard characters. The following command sequence will type out all of the batch files in a specific directory onto the console display device. IF EXIST c:\batch\*.bat FOR %%L IN (*.bat) DO TYPE %%L However, when used this way, TYPE no longer understands the redirection symbol, so it is no longer possible to redirect the output to the printer. This may be due to an inherent limitation on DOS's ability to process nested commands. It is probably due to an inherent limitation in the TYPE command. One of the frustrations of writing batch files is occasionally running across this kind of unexpected blind spot in DOS's own commands or its Batch File Control Language. Removing the IF EXIST test at the beginning of that last command reinstates TYPE's ability to understand redirection again and the following command will type all the batch files in the C:\BATCH directory onto the printer. FOR %%L IN (*.bat) DO TYPE %%L >PRN To be sure that at least one batch file exists in the directory requires a separate IF test ahead of this FOR IN DO command. Users can generate the same effect at the DOS prompt by typing the same command with a single percent sign, as follows. FOR %L IN (*.bat) DO TYPE %L >PRN One clever trick that is possible with the IF EXIST command is testing for the existence of a directory. While the IF EXIST test was not specifically designed to test for directories, there is a simple way to do it. The MS-DOS 5.0 "User's Guide and Reference" describes how to do it in Chapter 14, where it describes the IF command. See also the June 11, 1991 edition of PC Magazine, page 450 and the April 1990 edition of PC World, page 216 for additional information. The trick is to recognize that every directory contains the files called NUL, PRN, AUX and CON, among others. These are phantom files that only seem to exist in each directory because they are internal names that DOS uses. The IF EXIST test can check for the existence of a directory by testing for the existence of the NUL file, for example, in that directory. It is easy to test a directory's existence and, if necessary, create the directory in one step, as follows. IF NOT EXIST c:\TESTUTIL\nul MD c:\testutil NUL exists in every directory. When NUL can't be found in the TESTUTIL directory, then the TESTUTIL directory does not exist. If the TESTUTIL directory does not exist, the MD (MKDIR) command will create it. If the TESTUTIL directory does exist, the IF command will prevent the MD command from attempting to create it again. PRACTICE THESE TECHNIQUES Using the various IF commands and the FOR IN DO command is not as intimidating as it might appear. It takes practice to become a good programmer in any language. A good source for quick information about the Batch File Control Language is the Lab Notes section of the January 30, 1990 edition of PC Magazine. Another good source is the two part series by Paul Somerson in the November and December 1991 editions of PC/Computing. Try writing a version of TEST_BAT.BAT. Include tests to be sure the drive, the directory and the application program were specified and that all exist. What are you going to do if the application program also requires command line parameters of its own? That will require putting more than four strings on the command line. Then how will you test to see if all the data was supplied? Read about the SHIFT command and see if you can find a way to use it. Can your batch file run a program that requires 9 (or more) parameters of its own? Users, when specifying the path may or may not include a final back slash (\). How will you handle both possibilities? Test your own version of TEST_BAT.BAT. How much trouble will users have remembering the specific syntax? Will your version catch every possible error that users might make? As advertised, this completes the introduction to the IF command. It is not the last word on using the IF command in normal batch file programming. We will be using it again and again. Next month we'll back track a little to examine the pros and cons of various device drivers that you might include in CONFIG.SYS. I will also include a discussion of alternatives to BOOTCON. BOOTCON is not very expensive and it really is the best way I've found to deal with multiple configurations. There are some even cheaper alternatives that you might want to consider, however. KEY WORDS %%variable (FOR IN DO variable) %0 = Batch File Name %1 %2 %3 %4 %5 %6 %7 %8 %9 %variable (FOR IN DO as DOS Prompt) %Variable_Name% = DOS Environment Variable * (Any string) ? (Any Character) AUX Batch File Batch File Replaceable Paramters BFCL (Batch File Control Language) BOOTCON Case Sensitive Test (IF [NOT] "string1"=="string2") CON (Console = Keyboard + Monitor) Command Line Parameter COMMAND.COM Command_to_Execute Defined String Set (from FOR IN DO) Delimiter (space, comma, semicolon, and equal sign) Descending Cascade DOS DOS Environment [Variable] Double Equal Sign (==) ECHO Executable Program Exit Code External DOS Commands Floppy Disk FOR IN DO GOTO Greater Than Sign (>) Hard Disk IF Command IF ERRORLEVEL test_value command_to_execute IF EXIST filename command_to_execut IF NOT ERRORLEVEL test_value command_to_execute IF NOT EXIST filename command_to_execute IF NOT "string1"=="string2" command_to_execute IF "string1"=="string2" command_to_execute Internal DOS Commands Less Than Sign (<) Literal String Lotus 1-2-3 (from Lotus Development Corporation) Lotus Development Corporation MD (MKDIR) Microsoft MS-DOS User's Guide and Reference, for DOS 5.0 MS-DOS Batch File Programming - 2nd Edition, by Ronny Richardson Nested IF Commands NUL Null String PC/Computing - November 1991 PC/Computing - December 1991 PC Magazine - January 30, 1990 PC Magazine - June 11, 1991 PC World - April 1990 Pending GOTO Piping Symbol (|) PRN Redirection and Piping (the ">", "<" and "|" symbols) Replaceable Parameters SHIFT String Comparison String Set (from FOR IN DO) String Variable TESTUTIL Directory TEST_BAT.BAT Test_Value TYPE Undefined String Variable Wildcard Characters (the "*" and "?" symbols) Word Perfect Corporation WP (from Word Perfect Corporation)