Ch 11 Advanced Batch Files - Del Mar College



Chapter 11

Advanced Batch Files

LECTURE NOTES

|CHAPTER OUTLINE |TEACHING SUGGESTIONS |

|Chapter Overview | |

| |Slides 2-5 |

|Quick review of batch file commands learned in earlier chapters. | |

|Advanced features of these commands will be explained and used. |Chapter Overview duplicated in PowerPoint slides. |

|Will explain the purpose and function of remaining batch file commands and |After completion of lecture, suggest to students that they review |

|then will use these commands to write sophisticated batch files. |Objectives and Outcomes found on first page of chapter as a check to see |

|Will refine techniques in working with environment. |if they have mastered concepts. |

| | |

|BATCH FILE COMMANDS | |

|Batch File Commands | |

|Batch file rules. | |

|Has .BAT or .CMD as file extension. | |

|Must be ASCII file. |SECTION 11.1 (pp. 548-549) |

|Must include legitimate commands. |Slides 6-10 |

|Create generic batch files using replaceable parameters. | |

|Are not case-sensitive. |Already used ECHO, PAUSE, and REM |

|Can use any command in batch file that can be used on the command line. |Stress that batch files are similar to programming (logic) but not as |

|Many special batch file commands. |powerful. May find it useful to compare to macros in applications. |

|See PowerPoint slides # for list of commands and their purposes. | |

|Batch files have a limited vocabulary, syntax, and programming logic. | |

|Limited in kind of programming they can do. | |

|Not as versatile as "real" programming languages. | |

| | |

| | |

| | |

|A REVIEW OF THE REM, PAUSE, AND ECHO COMMANDS | |

|A Review of the REM, PAUSE, and ECHO Commands | |

|REM. | |

|Used to document batch files. | |

|Up to string of 123 characters. | |

|ECHO on - displays but does not execute what follows REM. | |

|Won't display if ECHO is off. | |

|Placing REM in front of a command will disable but not delete that specific| |

|line. |SECTION 11.2 (p. 549) |

|Batch file or CONFIG.SYS file will continue to execute. |Slides 11-15 |

|Disables line without deleting it. | |

|PAUSE. |Document = Explaining the purpose a file serves. |

| + C or + interrupts program. |Conditional processing = Comparing two items that yields true or false |

|Temporarily stops executing batch file. |value. |

|Will not continue until user presses a key. |- Program can be directed to take action once value is determined. |

|Will not do any conditional processing. |PAUSE command. |

|ECHO. |- Stops execution of batch file itself – not execution of .EXE or .COM |

|Used on command line or in batch file. |program. |

|Controls printing of messages on screen when batch file is run. |- If batch file called an external command & OS in middle of executing |

|ECHO ON |command – will finish job before exiting batch file. |

|(Default) displays all commands to screen along with output. | |

|Useful when tracking operation of a batch file |Discussion Question (1) - What is the function of the REM, ECHO, and |

|Clutters screen when batch file runs successfully |PAUSE commands? |

|ECHO OFF |Discussion Question (2) - What happens in a batch file if ECHO is set to|

|Displays only output of commands to screen. |OFF? |

|ECHO displays text string to screen. |Discussion Question (3) - What happens in a batch file if you precede the|

|Precede ECHO OFF with @ and “ECHO OFF” will not appear on the screen. |ECHO OFF switch with the @? |

| | |

| | |

|ADVANCED FEATURES OF ECHO AND REM | |

|Advanced Features of ECHO and REM | |

|REM slows processing of a batch file. | |

|Recognized by OS as command and must be processed. | |

|Replace REM with double colon (::) for faster processing. | |

|Label - single colon followed by anything. | |

|Using double colon (::) because labels skipped by OS. | |

|With ECHO OFF, messages still come on screen. | |

|Redirecting output to NUL device eliminates standard output messages. | |

|Will not suppress messages like “File not found”. | |

|To generate blank line on screen: | |

|Use ECHO followed by a period (ECHO.). | |

|No space between ECHO and period. | |

|Using will not work in batch files. | |

| | |

|ACTIVITY—USING ECHO AND NUL | |

|Using ECHO and NUL | |

|DATA disk in Drive A, A:\> displayed. | |

|Activity steps. | |

|Use editor to create/save batch file called ONE.BAT press enter only where | |

|indicated | |

|:: This is a test of a batch file using | |

|:: different features. | |

|COPY CAROLYN.FIL BOOK.FIL | |

| | |

|TYPE BOOK.FIL | |

|ECHO | |

|DEL BOOK.FIL | |

|COPY NO.FIL BOOK.FIL | |

| | |

| | |

| |SECTION 11.3 (pp. 549-550) |

| |Slides 16-20 |

| | |

| |Double colon provides faster processing. |

| | |

|Close Editor and key in TYPE ONE.BAT |Discussion Question (4) - What is a NUL device? Why would you use a NUL |

|Key in: ONE |device? |

|Edit/save ONE.BAT so it looks as follows: |Discussion Question (5) - How can you place a blank line in a batch file?|

|@ECHO OFF | |

|:: This is a test of a batch file using | |

|:: different features | |

|COPY CAROLYN.FIL BOOK.FIL > NUL | |

|ECHO. | |

|TYPE BOOK.FIL | |

|ECHO. | |

|DEL BOOK.FIL | |

|COPY NO.FIL BOOK.FIL > NUL | |

|Key in: ONE | |

|Activity completed. | |

| | |

|THE GOTO COMMAND | |

|The GOTO Command | |

|Use GOTO command to have batch file constructed to behave like a program. | |

|Allows looping & branching within batch files. | |

|Can stop loop | |

|Use IF statement or | |

|Break into batch file - + C. | |

|Works in conjunction with a label to create a loop. | |

|Processes command following label. | |

|Label. | |

|Do not confuse with volume label on a disk. | |

|Name chosen to flag or identify the location in batch file. | |

|Preceded by colon (:). |SECTION 11.4 (pp. 550-551) |

|Labels must be unique. |Slide 21 |

|Maximum length - 8 characters. | |

|Not a command. |Pressing in batch files demonstrates that getting a blank line is|

|Batch file goes to label – carries out command followed on line after |not as obvious as it seems. Nor can you simply place ECHO in the batch |

|label. |file - reports status. |

|Not case sensitive – but make cases same. |Use :: for faster processing. |

|Has one parameter – GOTO label. |Redirecting output to NUL device - no messages shown on screen |

|Double colon ensures that OS will disregard line since colon may not be |Using @ before ECHO OFF = “ECHO OFF” not shown. |

|used as label name. |Creating blank line in batch file with ECHO. |

| | |

| | |

| | |

|ACTIVITY—USING THE GOTO COMMAND | |

|Using the GOTO Command | |

|DATA disk in Drive A with A:\> displayed. | |

|Activity steps. | |

|Use text editor to create/save batch file called REPEAT.BAT so it looks as |May want to have a demo disk and write the batch files prior to class. |

|follows: |Are on the Instructor’s Manual CD. |

|REM This file displays many times the contents | |

|REM of a file | |

|:REPEAT | |

|TYPE %1 | |

|PAUSE | |

|GOTO REPEAT | |

|At system prompt, key in: REPEAT ASTRO.TXT | |

|Press several times to loop through file. | |

|Press + C then Y then | |

|Activity completed. | |

| | |

|THE SHIFT COMMAND | |

|The SHIFT Command | |

|Number of parameters on command line limited to 10 (%0 - %9). |SECTION 11.5 (pp. 551-552) |

|0% - represents batch file name itself. |Slides 22-25 |

|Really limited to 9 parameters. | |

|SHIFT moves parameters one position to the left, decreasing their number by|Loop = Operation that repeats steps until loop is stopped. |

|one. |Label = Ignored by OS until called with GOTO command. |

|With SHIFT can have unlimited # of parameters. |Discussion Question (6) - How can you create a loop in a batch file? How|

| |can you stop a loop from processing in a batch file? |

| |Discussion Question (7) - What is the purpose and function of the GOTO |

| |command? |

| |Discussion Question (8) - What is a label in a batch file? |

| | |

| | |

| | |

|ACTIVITY—USING THE SHIFT COMMAND | |

|Using the SHIFT Command | |

|DATA disk in Drive A with A:\> displayed. | |

|Activity steps. | |

|Key in: ECHO a b c d e | |

|Use editor to create/save batch file called ALPHA.BAT so it looks as | |

|follows: | |

|@ ECHO OFF | |

|ECHO %0 %1 %2 %3 | |

|SHIFT | |

|ECHO %0 %1 %2 %3 | |

|SHIFT | |

|ECHO %0 %1 %2 %3 | |

|SHIFT | |

|ECHO %0 %1 %2 %3 | |

|At system prompt key in: ALPHA a b c d e f | |

|Create /save new batch file UPDATE.BAT so it looks as follows: | |

|:DOIT | |

|COPY %1 /B + > NUL | |

|SHIFT | |

|PAUSE | |

|GOTO DOIT | |

|Key in: DIR APR.99 | |

|Key in: DIR APR.BUD |SECTION 11.6 (pp. 552-554) |

|Key in: UPDATE APR.99 APR.BUD |Slides 26-27 |

|Press twice then +C then Y | |

|Key in: DIR APR.99 |Purpose of EDIT/any editor is to create batch file. |

|Key in: DIR APR.BUD |Go over each line in Step 1 of activity on page 552. Analysis of each |

|Create/save a batch file called SIZE.BAT so it looks as follows: |line included at the end of this Chapter Outline document. |

|:TOP |Debug – see and repair any errors. label must be preceded by a colon |

|DIR %1 | FIND "Directory" >> TEMP.FIL |To execute a batch file, must be at system prompt - not in editor. |

|DIR %1 | FIND “bytes” | FIND /V “free” >> TEMP.FIL |Usefulness of loops. |

|SHIFT |Delete all files from many floppy disks. |

|GOTO TOP |Power Point Slide # shows batch file that will delete all files from many|

|TYPE TEMP.FIL |floppy disks. |

|PAUSE |Using /Q parameter – DEL command does not require Y or N |

|DEL TEMP.FIL | |

|Key in: SIZE CLASS TRIP |SECTION 11.7 (p. 554) |

|Press + C then Y |Slide 28 |

|Key in: TYPE TEMP.FIL | MORE | |

|Press + C |To execute batch file – key in batch file name followed by series of |

|Activity completed. |values. |

| |OS looks to command line for values needed to plug into batch file. |

|THE IF COMMAND |Does this based on position of particular parameters in command line. |

|The IF Command |Discussion Question (9) - What is the purpose and function of the SHIFT |

|Allows conditional processing of parts of batch files. |command? |

|Compares two items - determines if they are identical, or if one is greater|Discussion Question (10) -Why is it useful to shift parameters? |

|than the other. | |

|Comparison yields one of two values. |SECTION 11.8 (pp. 554-561) |

|True - items are identical |Slides 29-35 |

|False - items are not identical. | |

|Syntax: IF . |Most of batch files in this chapter are useful batch files so students |

|Condition true – Command executed. |can not only see how the principles work but also see practical |

|Condition false: |demonstrations of what one can do with batch files. |

|Command not executed. |- Also show the necessary analytical skills to debug programs - |

|Batch file falls through to next command line in batch file. |problem-solving skills. |

| |Can keep date log – not dependent on file modification date. |

|IF can check for three conditions. |SHIFT command. |

|Whether two sets of characters are or are not identical. |- Displays 5 + parameters and places echoing parameters in batch file. |

|Whether or not a file exists. |- Moves each parameter over by one position. |

|Value of variable in ERRORLEVEL |ECHO command = Echoes what is keyed in. |

|- ERRORLEVEL is a number that a program can set depending on the outcome of|+ sign tells OS to concatenate files. |

|a process. |Contents of file ended when see EOF. |

| |- Typically + Z. |

| |- Use COPY command – places second + Z at end of file. |

|THE IF COMMAND USING STRINGS |- This creates problem. |

|The IF Command using Strings |- Solve by copying file in binary mode. |

|IF can be used to compare strings. |/B switch – tells OS to copy file in binary mode. |

|Two equal signs (= =) separate what is to be compared. |Concatenated files with no switches – files copied in text mode. |

|Tell IF statement to GOTO a label or perform an operation whether the |>> used to see both name of directory and bytes in directory. |

|condition is true or false. | + C used to “break out”. |

| | |

|ACTIVITY—USING THE IF COMMAND WITH STRINGS | |

|Using the IF Command with Strings | |

|DATA disk in Drive A with A:\> displayed. | |

|Activity steps. | |

|Use editor to create/save batch file called GREET.BAT so it looks as | |

|follows: (No spaces between two equal signs.) | |

|IF %1==Carolyn GOTO Carolyn | |

|IF %1==Bette GOTO Bette | |

|ECHO Isn't anyone there? | |

|GOTO FINISH | |

|:Carolyn | |

|ECHO Greetings, Ms. Carolyn. | |

|GOTO FINISH | |

|:Bette |SECTION 11.9 (pp. 561-562) |

|ECHO Greetings, Ms. Bette. |Slides 36-39 |

|:FINISH | |

|Key in: |Conditional processing expressed: |

|GREET Carolyn then GREET Bette |- IF condition TRUE - DO something. |

|GREET JUAN then GREET BETTE |- IF condition FALSE – DO NOTHING. |

|Activity completed. |Syntax on power point slide # |

| |IF [NOT] ERRORLEVEL number command |

|TESTING FOR NULL VALUES |IF [NOT] string1==string2 command |

|Testing for NULL Values |IF [NOT] EXIST filename command |

|Activity 11.11 tested for exact match of character strings. |NOT – WXP carries out command if condition false |

| |ERRORLEVEL number – true condition if last program run returned exist |

| |code equal to or greater than number specified |

| |string1-==string2 – true condition if specified text strings match |

|If used SHIFT until all parameters used – end up in endless loop. |EXIST filename – true condition if specified filename exists |

|Can test to see if string matches. | |

|Can test for a null value = literally testing for nothing (no data). |Discussion Question (11) - How can you determine whether or not a file |

|Even though nothing is there, there must be "something" to confirm the |exists? |

|"nothing." |Discussion Question (12) - What is the purpose and function of the IF |

|To test for "nothing" must place a value in test that will give you |command? |

|nothing. |Discussion Question (13) - Give the syntax of the IF command and explain |

|Variety of methods for testing null values. |each part of the syntax. |

|Use quotation marks so that your statement becomes: | |

|IF "%1"= ="" GOTO LABEL | |

|Above means, "If nothing there, GOTO somewhere else." | |

|Use void: (can use any word) |SECTION 11.10 (p. 562) |

|IF %1void= = GOTO LABEL |Slides 40-41 |

|Use backslash (\): | |

|IF \%1\= =\\ GOTO LABEL |Condition true when strings match. |

| |Condition false when strings do not match. |

|ACTIVITY—USING NULL VALUES | |

|Using NULL Values | |

|Note: DATA disk in Drive A with A: \> displayed. | |

|Activity steps. | |

|Edit and save file called UPDATE.BAT to look as follows: | |

|:DOIT | |

|IF "%1"=="" GOTO END |SECTION 11.11 (pp. 562-565) |

|COPY %1 /B + > NUL |Slide 42 |

|SHIFT | |

|PAUSE |Do not use ECHO OFF as students cannot see the results of the |

|GOTO DOIT |tests/commands when you execute the batch files. |

|:END |Note how case matters. |

|Key in: |Add /I parameter immediately following the IF statement to ignore case. |

|DIR CAROLYN.FIL |Remind students that batch file replaceable parameters get value from |

|UPDATE CAROLYN.FIL |position on command line. |

|Press | |

|Key in: DIR CAROLYN.FIL | |

|Edit/save SIZE.BAT file to look as follows: | |

|:TOP | |

|IF %1nothing==nothing GOTO END | |

|DIR %1 | FIND "Directory" >> TEMP.FIL | |

|DIR %1 | FIND "bytes" | FIND /V "free" >> TEMP.FIL | |

|SHIFT | |

|GOTO TOP | |

| | |

| | |

|TYPE TEMP.FIL | |

|PAUSE | |

|DEL TEMP.FIL |SECTION 11.12 (p. 565) |

|:END |Slides 43-47 |

|Key in: | |

|DEL TEMP.FIL |Discuss results if value is true/not true. |

|SIZE CLASS TRIP |See Section 11.9, p. 597. |

|TYPE TEMP.FIL | |

|Activity completed. | |

| | |

|THE IF EXIST/IF NOT EXIST COMMAND |Discussion Question (14) - What does it mean to test for a null value? |

|The IF EXIST/IF NOT EXIST Command |Discussion Question (15) - How can you test for a null value? Why would |

|Checks for existence/non-existence of a specified file. |you test for a null value? |

|Using IF EXIST command. | |

|If file exists | |

|Condition is true | |

|Processing passes to specified GOTO location or to command following IF | |

|statement. | |

|If file does not exist: | |

|Condition is false. | |

|OS ignores command in IF clause. | |

|Batch process reads next line in file. | |

|Using IF NOT EXIST command. | |

|If file does not exist: | |

|Condition is true. | |

|Processing passes to specified GOTO location or to command following IF NOT| |

|statement. | |

|If file exists: | |

|Condition is false. | |

|Batch process reads next line in file. | |

| | |

| | |

|ACTIVITY—USING IF EXIST TO TEST FOR A FILE | |

|Using IF EXIST to Test for a File | |

|Note: DATA disk in Drive A with A: \> displayed. |SECTION 11.13 (pp. 565-568) |

| |Slide 48 |

| | |

| |Testing for a null value can be a difficult concept for students. |

| |Point out that if you do not test for the end of the data on the command |

| |line, you will create an endless loop. |

| |There is also a device named NUL that is different from a null value. |

| |NUL device literally means nowhere - thus, you can send the standard |

|Activity steps. |output of commands (1 file copied) to the NUL device, which means the |

|Use any text editor to create/save a file called RENDIR.BAT to look as |message will not be displayed. |

|follows: |NUL is a device name just as is CON, PRN, LPT1, etc. |

|IF \%1\==\\ GOTO end | |

|IF NOT \%2\==\\ GOTO next | |

|ECHO You must include a destination name | |

|ECHO for the new directory name. | |

|GOTO end | |

|:next | |

|IF EXIST %1 GOTO message | |

|REN %1 %2 | |

|GOTO end | |

|:message | |

|ECHO This is a file, not a directory. | |

|:end | |

|Key in: RENDIR JAN.99 LAST | |

|Key in: RENDIR TEST OLDER | |

|Edit RENDIR.BAT file so IF NOT EXIST%1\NUL GOTO message replaces IF EXIST | |

|%1GOTO message. | |

|Key in: RENDIR TEST OLDER |SECTION 11.14 (p. 568) |

|Edit/save SIZE.BAT file to look as follows: |Slides 49-51 |

|IF EXIST TEMP.FIL DEL TEMP.FIL | |

|:TOP |Batch file will process based on the condition. |

|IF %1nothing==nothing GOTO END |IF EXIST/IF NOT EXIST works only with file names and not with directory |

|IF NOT EXIST %1\NUL GOTO NEXT |names. |

|DIR %1 | FIND "Directory" >> TEMP.FIL |Discussion Question (16) - What is the purpose and function of the IF |

|DIR %1 | FIND "bytes" | FIND /V "free" >> TEMP.FIL |EXIST/IF NOT EXIST command? |

|:NEXT | |

|SHIFT | |

|GOTO TOP | |

|:END | |

|TYPE TEMP.FIL | |

|PAUSE | |

|DEL TEMP.FIL | |

|Key in: SIZE CLASS JUP.PAR TRIP | |

|Press | |

|Activity completed. | |

| | |

| | |

|IF ERRORLEVEL COMMAND TESTING | |

|The IF ERRORLEVEL Command Testing | |

|Program can set exit code when it finishes executing. | |

|Batch file tests this exit code with IF ERRORLEVEL statement. | |

| | |

| | |

| | |

| | |

|Exit code doesn’t test for a match with ERRORLEVEL, but determines if it is| |

|greater than or equal to it. | |

|Test IF ERRORLEVEL 0 will always be true – every possible exit code is | |

|greater than or equal to 0. | |

| | |

|ACTIVITY—USING IF ERRORLEVEL WITH COPY | |

|Using IF ERRORLEVEL with COPY | |

|DATA disk in Drive A with A:\> displayed. | |

|Activity steps. | |

|Use any text editor to create/save a file called ERROR.BAT to look as | |

|follows: | |

|COPY %1 %2 | |

|IF ERRORLEVEL 1 GOTO NOTOK | |

|IF ERRORLEVEL 0 GOTO OK | |

|:NOTOK | |

|ECHO There are no %1 files. Try again. |SECTION 11.15 (pp. 568-573) |

|GOTOEND |Slides 52-56 |

|:OK | |

|ECHO You copied the %1 files | |

|successfully. | |

|:END | |

|Key in: ERROR *.TXT OLDER | |

|Key in: ERROR *.NON OLDER | |

|Activity completed. | |

| | |

|WRITING PROGRAMS TO TEST FOR KEY CODES | |

|Writing Programs to Test for Key Codes | |

|Exit codes. | |

|Set by OS. |Table on pages 569-570 analyzes batch file one line at a time. This same |

|Created by writing small programs that are based upon some activity. |table is included at the end of this Chapter Outline document. |

|Can write program that identifies which key on a keyboard was pressed and |Can express/reduce item to a true/false test. Either it is true, or it is|

|report which key it was. |false. |

|Can do this activity because each time key is pressed- identified by a 1- |Remind students that each IF is testing for a true condition. |

|or 2-digit scan code. |If statement is true, then command will be processed. |

|Two things reported when you press a key on the keyboard: |If condition is false, command ignored and the next line in the batch |

|First, that a key was pressed. |file will be processed. |

|Second, that the key was released. |On the other hand, if the statement is an IF NOT, you are testing for |

|Going to write a program that will report the scan code for any key that is|"truth" in reverse - if the condition is false, then the test is true and|

|pressed. |the command is processed. If the condition is true, the command will be |

|Once know reported code, can test for a specific key by using ERRORLEVEL in|ignored and the next line in the batch file will be processed. |

|the batch file. |IF EXIST/IF NOT EXIST will test only for the existence/non-existence of a|

|Batch file then acts based upon the reported code. |file. |

|Program must be written in 0's and 1's - the "bits and bytes" the computer |Can "fool" IF to test for a directory by using IF %1\NUL. The NUL in the |

|understands. |statement will test for a directory. |

|Several ways to write a program. |- Null device does not exist in every directory. |

|Use programming language. |- NUL discards anything sent to it. |

|Use an OS utility program called DEBUG. | |

|DEBUG. | |

|Allows testing and debugging of executable files - those with .COM or .EXE | |

|file extensions. | |

|Small program that has its own commands and syntax - you could write a .COM| |

|program directly with DEBUG. | |

|Unless a student is a programming expert, they probably don't want to do | |

|this. | |

|Easiest way to use DEBUG is to create a script file. | |

|Script = set of instructions that you can write with any ASCII editor. | |

|Once the script is written, you can "feed" it to the DEBUG program via | |

|redirection (DEBUG < SCRIPT.FIL). |SECTION 11.16 (p.573) |

|DEBUG will then convert the script file to an executable program with a |Slides 56-58 |

|.COM file extension. | |

|This process is the easiest way to create a file that will report the scan |Students need to understand that exit codes must be listed in descending |

|code for any key that is pressed. |order when using IF ERRORLEVEL and in ascending order when using IF NOT |

|The program that will be created will be called (Activity 11.19).|ERRORLEVEL. |

| | |

|ACTIVITY—WRITING A SCRIPT FILE | |

|Writing a Script File | |

|DATA disk in Drive A with A:\> displayed. |Discussion Question (17) - Explain the purpose and function of IF |

| |ERRORLEVEL command. |

| | |

| | |

| | |

| | |

|Activity steps. | |

|Use any text editor to create/save a file called REPLY.SCR to look as | |

|follows: |SECTION 11.17 (pp. 574-575) |

|e 100 b4 08 cd 21 3c 00 75 02 cd 21 b4 4c cd 21 |[pic] Slide 59 |

|rcx | |

|e | |

|n | |

|w | |

|q | |

|Key in: DEBUG < REPLY.SCR | |

|Key in: DIR | |

|Use any text editor to create/save a file called KEYING.BAT to look as | |

|follows: | |

|ECHO PRESS F1 TO CLEAR THE SCREEN. | |

|ECHO PRESS F2 TO DISPLAY THE DIRECTORY. | |

|ECHO PRESS ANY OTHER KEY TO EXIT. | |

|REPLY | |

|IF ERRORLEVEL 61 GOTO END | |

|IF ERRORLEVEL 60 GOTO F2 | |

|IF ERRORLEVEL 59 GOTO F1 | |

|GOTO END | |

|:F1 | |

|CLS | |

|GOTO END | |

|:F2 | |

|DIR | |

|:END |SECTION 11.18 (pp. 575-577) |

|Key in: |Slides 60-69 |

|KEYING then then KEYING then | |

|Activity completed. |Scan code = Code computer receives when key is pressed. |

| |- Code translated by OS and application to indicate which key was |

| |pressed. |

|THE ENVIRONMENT |See Appendix G for list of scan codes for all the keys. |

|The Environment |Script file = Set of instructions that can be written in any ASCII |

|Area OS sets aside in memory where data can be stored. |editor. |

|Acts as a scratch pad where notes kept about items OS system needs to know.|- Redirect instructions into program such as DEBUG to convert script file|

|OS places/keeps location of file in environment. |into executable program. |

|Applications can read items in environment and can post own messages there.|- Has .COM file extension. |

|Programs can get value of variable and use it to modify their operation. |- Simplest way to create file that will report scan code for any key that|

| |is pressed. |

| | |

|OS can store data in memory. | |

|Two strings: |Discussion Question (18) - What is a script file? How can you create |

|Name of variable. |one? |

|Value of variable. |Discussion Question (19) -What is a scan code? |

|Environmental variable is name assigned to string (value) of data. | |

|User can set environmental variables. | |

|Some common variables set when Windows started. | |

|USERNAME, USERPROFILE, PATH, PROMPT. | |

|Location of CMD.EXE file. | |

|User can also leave messages in the environment. | |

|User leaves a message by using the SET command. | |

|Environmental variables set in OS remain in effect for entire work session.| |

|Environmental variables set in Command Prompt window or in batch files | |

|executed in the MS-DOS window will remain in effect only during that | |

|command prompt session. | |

|While values are in effect, use the syntax %variable%. | |

|SET syntax: SET [variable=[string]] | |

|Variable - specifies environment -variable name. | |

|String - specifies series of characters to assign to the variable. | |

|SET without parameters – displays current environment variables. | |

|SET command followed by a letter – lists any environmental variables that | |

|begin with that letter. | |

| | |

|ACTIVITY—USING SET AND THE ENVIRONMENTAL VARIABLES | |

|Using SET and the Environmental Variables | |

|If environment display is too long to fit on one screen use MORE filter. | |

| | |

| | |

| | |

| | |

| | |

|Activity steps. | |

|Key in: SET | |

|If used MORE filter return to prompt or press Q | |

|Key in: | |

|SET U then SET S | |

|ECHO %PATH% | |

|ECHO %SystemRoot% | |

|C: then CD %systemroot% | |

|CD %userprofile% then DIR/AH | |

|DIR “local settings”\TEMP\~*.tmp | |

|DEL %TEMP%\~*.tmp | |

|DIR %TEMP%\~*.tmp | |

|CD \ then A: | |

|Activity completed. | |

| | |

|USING SET AND THE ENVIRONMENT IN BATCH FILES | |

|Using SET and the Environment in Batch Files | |

|Can use built-in environmental variables that Windows sets/uses. | |

|Can set own environmental variables. | |

|Can give them name/value in batch file or command line. |SECTION 11.19 (pp. 577-581) |

|Set variables only good for that session of Command Prompt Window. |Slide 70 |

| | |

|ACTIVITY—USING SET AND THE ENVIRONMENT IN BATCH FILES |Script file converted into bytes that make it a program by redirecting it|

|Using SET and the Environment in Batch Files |to DEBUG. |

|DATA disk in Drive A with A:\> displayed. | |

|Activity steps. | |

|Close Command Prompt window | |

|Reopen Command Prompt window and return to A prompt. |May want to create file for students and let them copy it or |

|Create/save TESTIT.BAT batch file that looks as follows: |download it. |

|@ECHO OFF |Critical when writing script files that it is exact, i.e., zeros not the |

|ECHO %PATH% |letter o, etc. |

|ECHO. |Remind students that error codes are tested for equal to or greater than |

|Key in: |the value specified. |

|TESTIT |IF ERRORLEVEL - descending order. |

|SET TODAY=C:\WUGXP\*.FP |IF NOT ERRORLEVEL - ascending order. |

|SET | |

|Create/save SETTING.BAT batch file that looks as follows: | |

|DIR %today% | |

|ECHO %TODAY% | |

| | |

| | |

|Key in: | |

|SETTING | |

|SET today=C:\WUGXP\.TMP | |

|SETTING then SET TODAY= | |

|SET T then SET TODAY=MONDAY | |

|ECHO %TODAY% then SET T | |

|Close Command Prompt window | |

|Reopen Command Prompt window and return to A prompt. | |

|Key in: SET T | |

|Create/save ADD.BAT batch file that looks as follows: | |

|IF "%1"=="" GOTO END | |

|PATH > OLDPATH.BAT | |

|:TOP | |

|PATH %PATH%;%1 | |

|SHIFT | |

|IF NOT \%1\==\\ GOTO TOP | |

|:END | |

|Key in: | |

|PATH > ORIGPATH.BAT | |

|ADD A:\ then ORIGPATH | |

|ADD A:\;A:\OLDER;A:\CLASS | |

|PATH then ORIGPATH | |

|Activity completed. | |

| | |

|THE DIRCMD ENVIRONMENTAL VARIABLE |SECTION 11.20 (pp. 580-581) |

|The DIRCMD Environmental Variable |Slides 71-80 |

|Can place/use variables in environment. | |

|DIRCMD environmental variable. |Variable = Value that can change depending on conditions or on |

|With SET to preset DIR command parameters/switches. |information passed to program. |

|With ERRORLEVEL to write batch files to change way DIR displays information|DATA consists of constants or fixed values that never change and variable|

|for current MS-DOS work session. |values that do change. |

| |Expression is any legal combination of symbols that represents a value. |

|ACTIVITY—USING DIRCMD | |

|Using DIRCMD | |

|DATA disk in Drive A with A:\> displayed. | |

| |Setting environmental values and using them in batch files is extremely |

| |useful. |

| |Environmental variables commonly used in all OS’s. |

| |By using ORIGPATH, even on a network, students will be returned to |

| |network path. |

| |ADD very useful for adding new subdirectories to existing path. |

| | |

| |Discussion Question (20) - Give the syntax of the SET command and explain|

|Activity steps. |each part of the syntax. |

|Create/save batch file MY.BAT | |

|@ECHO OFF | |

|CLS | |

|ECHO. | |

|ECHO. | |

|ECHO How do you want your directory displayed? | |

|ECHO. | |

|ECHO 1. Files only arranged by file name. A to Z | |

|ECHO 2. Files only arranged by file name. Z to A. | |

|ECHO 3. Files only arranged by file extension. A to Z | |

|ECHO 4. Files only arranged by file extension. Z to A | |

|ECHO 5. Directory displays in default mode. | |

|ECHO. | |

|ECHO PLEASE SELECT A NUMBER. | |

|ECHO. | |

|REPLY | |

|ECHO. | |

|IF ERRORLEVEL 49 IF NOT ERRORLEVEL 50 SET DIRCMD=/ON/A-D | |

|IF ERRORLEVEL 50 IF NOT ERRORLEVEL 51 SET DIRCMD=/O-N/A-D | |

|IF ERRORLEVEL 51IF NOT ERRORLEVEL 52 SET DIRCMD=/OE/A-D | |

|IF ERRORLEVEL 52 IF NOT ERRORLEVEL 53 SET DIRCMD=/O- E/A-D | |

|IF ERRORLEVE 53 IF NOT ERRORLEVEL 54 SET DIRCMD= | |

|Key in: | |

|MY then 4 then SET D | |

|DIR CLASS then MY then 5 | |

|SET D | |

|Activity completed. | |

| | |

|THE FOR…IN…DO COMMAND | |

|The FOR…IN…DO Command |SECTION 11.21 (pp. 581-585) |

|Can be issued at command line or placed in batch file. |Slides 81-82 |

|Allows repetitive processing within batch files. | |

|FOR allows you to use a single command to issue several commands at once. |Command processor must be in memory when keying in command. |

|The command can DO something FOR every value in a specified set. | |

| | |

| | |

|FOR…IN…DO syntax (at command line): | |

|FOR %variable% IN (set) DO command |Using MORE. |

|[command-parameters] |- Pressing - moves one line at a time in screen display. |

|%variable - specifies a replaceable parameter. |- Pressing - goes to end of file. |

|(set) - specifies a set of one or more files. Wildcards may be used. |SET with letter of alphabet – all environmental variables beginning with |

|Command - specifies the command to carry out for each file. |letter displayed. |

|Command-parameters - specifies parameters or switches for the specified |See value of environmental variable – ECHO and enclose environmental |

|command. |variable name seeking with percent signs. |

|FOR…IN…DO syntax (batch program): |Environmental variable can be used with commands. |

|Use %%variable instead of %variable. |Use environmental variable to change directories (Shortcut). |

|Batch file variable - arbitrary single letter. | |

|Double percent sign with letter (%%a) distinguishes batch file variable | |

|from replaceable variable (%1). | |

|Allows the user to loop through a file for predefined list of values. |SECTION 11.22 (p. 585) |

|OS gets values from position in command line. |Slides 83-84 |

|The set enclosed in parentheses. | |

|Values in set used to DO some command. |Exit command prompt set values no longer available next time command |

|Items in set separated by spaces or commas. |prompt opened. |

|Wildcards may be used. | |

| | |

|ACTIVITY—USING THE FOR…IN…DO COMMAND | |

|Activity: Using FOR...IN...DO Command. | |

|DATA disk in Drive A and A:\> displayed. | |

|Note 2: Look at command line going to use in Step 1. In English, command | |

|says: Using the variable %a to hold each value in the set (what is in the | |

|parentheses), do the command (Type) to each value in the set (%a). |SECTION 11.23 (pp. 585-590) |

| |Slide 85 |

| | |

| |Can set environmental value and use it in a batch file. |

| |Environmental variables set – deleted when Command Prompt window is |

|Activity steps. |closed. |

|Key in: FOR %a IN (*.99) DO TYPE %a |Environmental variables – not case sensitive. |

|Key in: FOR %x IN (APR99 NOFILE.EXT D.BAT) DO TYPE %x |To eliminate value – must set it at nothing. |

|Key in: FOR %y IN (APR.99,NOFILE.EXT,D.BAT) DO TYPE %y |Adding directory to PATH statement. |

|Key in: TYPE *.99 NOFILE.EXT | |

|Key in: FOR %a IN (*.99,NOFILE) DO IF EXIST %a TYPE %a | |

|Create/save batch file DO.BAT that looks as follows: | |

|FOR %%v IN (Patty Nicki Sandy Brian) DO ECHO %%v | |

|Key in: DO | |

|Create/save a batch file called PASS.BAT that looks as follows: | |

|FOR %%a IN (%USERS%) DO IF "%1"=="%%a" GOTO OKAY | |

|:NO | |

|ECHO You, %1, are NOT allowed in the system. | |

|GOTO END | |

|:OKAY | |

|ECHO Welcome %1 to my world of computers. | |

|:END | |

|Key in: SET USERS=Carolyn, Bette | |

|Key in: PASS Bette | |

|Key in: PASS Denzel | |

|Edit/save UPDATE.BAT to look as follows: | |

|:DOIT | |

|IF "%1"=="" GOTO END | |

|FOR %%v IN (%1) DO COPY %%v /b + > NUL | |

|SHIFT | |

|PAUSE | |

|GOTO DOIT | |

|:END | |

|Key in: MD BATCH | |

|Key in: ADD A:\BATCH | |

|Key in: MOVE *.BAT BATCH | |

|Key in: MOVE REPLY*.* BATCH | |

|Key in: DIR *.SWT | |

|Key in: DIR *.CAP | |

|Key in: UPDATE *.SWT *.CAP | |

|Press until returned to prompt | |

|Key in: DIR *.SWT *.CAP | |

|Activity completed. | |

| | |

| | |

| | |

| | |

|MORE FEATURES OF THE FOR…IN…DO COMMAND | |

|More Features of the FOR…IN…DO Command | |

|May list environmental variables so they are divided and appear on separate| |

|lines. | |

|Use /R parameter (recursive). | |

|Command will search and perform actions on all subdirectories beneath it. | |

|Use tilde operator (~) to: | |

|Strip a file name of quotation marks. |SECTION 11.24 (p. 590) |

|Expand a variable. |Slide 86 |

|Select specific text from ASCII files. | |

| |Environment – area set-aside in memory. |

|ACTIVITY—USING THE ADDITIONAL FEATURES OF THE FOR…IN…DO COMMAND |Keying in SET (alone) – displays what is in environment. |

|Using Additional Features of the FOR…IN…DO Command |Discussion Question (21) - Explain the purpose and function of the DIRCMD|

|Note: DATA disk in Drive A with A: \> displayed. |environmental variable. |

|Activity steps. | |

|Key in: | |

|SET PATHEXT |SECTION 11.25 (pp590-593) |

|FOR %a IN (%pathext%) DO @ ECHO %a |Slide 87 |

|FOR %a IN (“Sandy and Patty.txt”, MERCUYRY.TXT) DO @ECHO %a | |

|FOR %a IN (“Sandy and Patty.txt”, MERCURY.TXT) DO @ECHO %~a |Using DIRCMD is an easy way to set preferences for the default values of |

|FOR %a IN (“Sandy and Patty.txt”, MERCURY.TXT) DO @REN %a “CZG %a” |DIR. Can eliminate the need for using parameters. |

|FOR %a IN (“Sandy and Patty.txt”, MERCURY.TXT) DO @ECHO %~a |Even easier than a batch file. |

|DIR CZG*.* | |

|DEL CZG*.* | |

|Key in following and then press : FOR %a IN (“Sandy and Patty.txt”, | |

|JUPITER.TXT) DO REN %a “CZG %~a” |Stress the IF ERRORLEVEL/IF NOT ERRORLEVEL to set specific range and then|

| |execute command preference. |

| | |

| | |

| | |

| | |

| | |

| | |

|Key in: | |

|COPY C:\UGXP\*.TXT TRIP | |

|FOR /R %a IN (SANDY*.*) DO @ECHO %a | |

|FOR /R %a IN (SANDY*.*) DO @ECHO %~nxa | |

|In batch file directory create PREFIX.BAT batch file. Use own name instead | |

|of “YourNameHere” | |

|@ECHO OFF | |

|REM YourNameHere | |

|REM Purpose of batch file is to add a new prefix to any file name. | |

|IF”1”==””GOTOMESSAGE | |

|IF”2”==””GOTOMESSAGE2 | |

|FOR /R %%a IN (%2) DO REN “%%~a” “%1 %%~nxa” | |

|GOTOEND | |

|:MESSAGE | |

|ECHO You must include a prefix you wish to use. | |

|ECHO Syntax is PREFIX prefix filename | |

|GOTOEND | |

|:MESSAGE2 | |

|ECHO You must include a file name you wish to rename. | |

|ECHO Syntax is PREFIX prefix filename | |

|GOTOEND | |

|:MESSAGE2 | |

|ECHO You must include a file name you wish to rename. | |

|ECHO Syntax is PREFIX prefix filename | |

|:END | |

|Be sure BATCH directory is in your path. Can add ADD.BAT to include it. | |

|In root of A:\ key in: DIR Sandy*.* /S |SECTION 11.26 (pp. 593-594) |

|Key in: |Slides 88-93 |

|PREFIX RBP SANDY* | |

|DIR *SANDY* /S then DIR RBP* /S |Difference between a variable and a parameter. |

|Create PERSON.BAT batch file in BATCH directory that looks as follows: |VARIABLE. |

|@ECHO OFF |- FOR statement – tells OS to get value from set chosen. |

|FOR /F “TOKENS=1,2,7” %%a IN (%1) DO ECHO %%b %%a %%c |- After executes command appearing after DO, FOR looks for next value in |

|Key in: |set. |

|CD \ then TYPE PERSONAL.FIL |- - Finds another value, %% represents something new – command executed |

|PERSON PERSONAL.FIL |with new value. |

|Edit PERSON.BAT file as follows: | |

|@ECHO OFF | |

|SORT < %1 > %2 |- - No more values in set – FOR stops processing |

|FOR /F “TOKENS=1,2,7” %%a IN (%2) DO ECHO %%b |PARAMETER. |

|%%a, %%c |- Set before batch file begins processing. |

|DEL %2 |GOTO loop as a vertical loop and FOR…IN…DO as a horizontal loop. |

| | |

| | |

|Key in: PERSON PERSONAL.FIL TEMP.FIL |Discussion Question (22) - What is the purpose and function of the |

|Edit PERSONAL.FIL and select the first five lines and copy them into a new |FOR…IN…DO command? |

|file called SHORT.FIL |Discussion Question (23) - Name two parameters you can use with the |

|Exit Edit and key in: PERSON SHORT.FIL TEMP.FIL |FOR…IN…DO command. |

|Edit SHORT.FIL file as follows: |Discussion Question (24) - Describe the purpose of those parameters. |

|Gillay;Carolyn;699 Lemon;Orange;CA;Professor |Discussion Question (25) - Give the syntax of the FOR..IN..DO command and|

|Panezich;Frank;689 Lake;Orange;CA;Teacher |explain each part of the syntax. |

|Tuttle;Steven;356 | |

|Embassy;Mission Viejo;CA;Juggler | |

|Maurdeff;Kathryn;550 | |

|Traver;Ann Arbor;MI;Teacher | |

|Maurdeff;Sonia;550 | |

|Traver;Ann Arbor;MI;Student | |

|Close SHORT.FIL Edit PERSON.BAT to look as follows: | |

|@ECHO OFF | |

|SORT < %1 > %2 | |

|FOR /F ”usebackq delilms=;TOKENS=1,2,6” %%a IN (%2) DO ECHO %%b %%a, %%c| |

|DEL %2 | |

|Key in: PERSON SHORT.FIL TEMP.FIL | |

|Activity completed. | |

| | |

|THE CALL COMMAND | |

|The CALL Command | |

|CALL allows you to run one batch file from within another. | |

|Second batch file is finished executing – returns control to first batch | |

|file. | |

|Without CALL, the original batch file will not continue after the second | |

|one is run. | |

| |SECTION 11.27 (pp. 594-601) |

|ACTIVITY—USING CALL |Slides 94-95 |

|Using CALL | |

|DATA disk in Drive A with A:\> displayed. |Space and comma between items in a set work same way. |

|You have executed command A:\BATCH\>ADD A:\BATCH at some time during |Variable letter chosen not important |

|current Command Prompt session. |Command line is case sensitive. |

| |Stress the following items. |

| |- % is used at the command line. |

| |- %% must be used in a batch file. |

| | |

| | |

| | |

|Activity steps. | |

|Key in: |Advantage of FOR…IN…DO - can set values in environment and then use them|

|CD BATCH |in a batch file. |

|COPY CON BELL.BAT |Stress that the %x can be any value, i.e., %j, %y, etc. Can demonstrate |

|ECHO + G 6 times |with several letters to show that it is an arbitrary assignment. |

| |Explain that this is a horizontal loop - process all items in the (set) |

|TYPE BELL.BAT |rather than a vertical loop as is the GOTO/label. |

|BELL |Point out that environmental variables can be used with FOR…IN…DO. |

|Create/save a batch file called BELLING.BAT in BATCH directory that looks |Caution: If closed Command Prompt window, have to issue following command|

|as follows: |to include the A:\BATCH directory in your path: A:\BATCH>A:\BATCH\ADD |

|COPY \*.ABC *.XYZ |A:\BATCH |

|DEL *.XYZ | |

|BELL | |

|Key in: BELLING | |

|Edit/save BELLING.BAT that looks as follows: | |

|COPY \*.ABC *.XYZ | |

|BELL | |

|REM You are about to delete the *.XYZ files. Are you sure? | |

|PAUSE | |

|DEL *.XYZ | |

|Key in: BELLING then DIR *.XYZ | |

|Edit/save BELLING.BAT that looks as follows: | |

|COPY \*.ABC *.XYZ | |

|CALL BELL | |

|REM You are about to delete the *.XYZ files. Are you sure? | |

|PAUSE | |

|DEL *.XYZ | |

|Key in: BELLING | |

|Press | |

|Key in: DIR *.XYZ | |

|Use COPY CON to create/save a batch file called HOME.DAT that looks as | |

|follows: | |

|COPY CON HOME.DAT | |

|SET HOME= | |

|Create/save HOMETO.BAT batch file in batch directory that looks as follows:| |

|COPY A:\BATCH\HOME.DAT A:\BATCH\HOMESAVE.BAT | |

|CD >> A:\BATCH\HOMESAVE.BAT | |

|CALL HOMESAVE.BAT | |

|DEL A:\BATCH\HOMESAVE.BAT | |

|Create/save a batch file HOME.BAT that contains the following: | |

|CD %HOME% | |

| | |

| | |

| | |

| | |

| | |

| | |

|Key in: | |

|PATH then SET H then CD \ | |

|CD WORK\ADS then HOMETO |SECTION 11.28 (p. 602) |

|SET H then CD \MEDIA\TV |Slides 96-97 |

|HOME then CD \ then ORIGPATH | |

|Activity completed. | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| |SECTION 11.29 (pp. 602-611) |

| |Slides 98-99 |

| | |

| |In batch file, variable names need to be preceded by two percent signs. |

| |Use FOR…IN…DO to display one line at a time. |

| |Tilde strips file name of quotation marks. |

| |Use quotation marks to add prefix or suffix to long file name. |

| |REN only needs file name. |

| |- Options preceded by ~ permits this. |

| |- n – forces variable to expand to only file name. |

| |- x – forces expansion of file extension. |

| |Can strip out specific fields in a text file. |

| |- /F parameter sets rules by which you extract data. |

| |Can delimit data. |

| |- Each field set off with a semicolon (could have used any character). |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| | |

| |SECTION 11.30 (pp. 611-612) |

| |Slide 100 |

| | |

| |Discussion Question (26) - Explain the purpose and function of the CALL |

| |command. |

| | |

| | |

| | |

| |SECTION 11.31 (pp. 612-619) |

| |Slides 101-102 |

| | |

| |When executing a program within a batch file, you are not returned to |

| |batch file unless you use CALL. |

| |Breakdown of the HOME.DAT batch file on page 617 |

| |Line 1 – Copies contents of data file to batch file. Now HOME>DAT |

| |contains SET HOME=. HOMESAVE.BAT not contains SETHOME |

| |Line 2 – takes whatever directory you are in and appends it to |

| |HOMESAVE.BAT. If your current directory is BATCH.HOMESAVE.BAT now has |

| |the contents of SET HOME=A:\BATCH |

| |Line 3 – executes batch file. HOMESAVE.BAYT now executes and sets the |

| |variable of HOME to A:\BATCH |

| |Line 4 – Deletes batch file. Now that environmental variable is set, no |

| |longer need batch file HOMESAVE.BAT |

Activity 11.6 - Using the GOTO Command

Line 1 - REM This file displays many times the contents

Line 2 - REM of a file

Line 3 - :REPEAT

Line 4 - TYPE %1

Line 5 - PAUSE

Line 6 -GOTO REPEAT

First two lines are remarks that will not execute.

Not including ECHO OFF because you want to see what is happening in batch file.

Omitting ECHOOFF is way to “debut a batch program

Third line : REPEAT) is a label – must be preceded by a colon

Fourth line simple TYPE Command with replaceable parameter

Fifth line - Pause command is placed here so you may see what is happening.

Sixth and last line is the loop.

The GOTO tells batch file to return to label. (:REPEAT)

It will then return to line 4 and execute the TYPE Com and

It will then read lines 5 and 6 and continually repeat the process.

Activity 11.15: Using IF EXIST to Test for a FILE

Batch File by Line Number Test TRUE Processing Test FALSE

1. IF \%1\= =\\ GOTO end User keys in Testing for User keys in

nothing for %1. null value. value for %1.

Since test is Since test is

true, action is false, action is

to go to line 12 to go to line 2.

2. IF NOT \%2\= =\\GOTO next User keys in Testing for User keys in

nothing for %2. null value value for %2.

Since test is Since test is

true, action is false, action is

to go to line 3. to go to line 6.

3. ECHO You must include a Message for

destination name user that he

or she did not

include a value.

4. ECHO for the new Continuation

directory name. of the message.

5. GOTO end Falls through to

the GOTO end

statement. Action

is to go to line 12.

6. :next Label referred

to in line 2.

7. IF EXIST %1 GOTO message User keys in Testing for User keys in

file name for value for %1. directory for

%1. Since test Is it a file or %1. Since test

is true, action is a directory? is false, action

to go to line 10. is to go to line 8.

8. REN %1 %2 Since %1 test is

false (not a file),

renaming directory

can proceed.

9. GOTO end After directory

is renamed, falls

through to GOTO end.

10. :message Label referred

to in line 2.

11. ECHO This is a file, not a Message that

directory. user used a file

name, not a

directory name.

12. :end

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download