Note the conditional statement that creates the directory only if it does not already exist. Also
note the looping structure using the GOTO statement with the COPY-FILES label.
54 SOFTWARE [CHAP. 4
:: myCopy.bat
:: Copies a set of files to a (possibly new) directory
:: called DUPLICAT
:: Wildcards (* and ?) may be Used in File Names
::
@ECHO OFF
::Stops the Batch File if no file is specified
IF "%1" == "" GOTO END
::Makes the new directory only if it does not exist already
IF NOT EXIST DUPLICAT MKDIR DUPLICAT
::Loop to copy all the files.
::Uses the DOS "SHIFT" command to move
:: each file name specified at the
:: command line to the "1" parameter,
:: until none is left to copy.
:COPY-FILES
XCOPY %1 DUPLICAT
SHIFT
IF "%1" == "" GOTO END
GOTO COPY-FILES
:END
These JCL scripting languages have very limited programming tools and primitive error-handling abilities.
They are very useful nonetheless, especially to system administrators who need quick ???one-off??? applications to
automate repetitive tasks.
The usefulness of scripting languages inspired many authors and inventors to develop new languages with
various features and conveniences. For text processing, for example, the languages awk, sed, and Perl are popular.
Pages:
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159