welcome back to the adventure this is Adam and today we're working with some
advanced batch command we have four commands that will be covering shift for
call and choice I have prepared sample batch files that will demonstrate what
each command does to start we will look at a batch file that uses the shift
command the shift command moves the list of parameters you type with the batch
command one position to the left say we type three parameters with a batch
command after the shift command is carried out once what was % 3 becomes %
to what was % 2 becomes % 1 and what was % 1 is gone this command allows a short
batch file to handle any number of parameters as for the batch file here we
start with at echo off then we have the label start which marks the beginning of
the commands that will be repeated for each parameter next the if command is
comparing the first parameter % 1 to the double quote marks which means null if
this is true that the first parameter is null then go to the labels done then we
have an echo command to display the names of the files being archived
followed by an if command that checks if the file to be archived is already on
drive a if it isn't the copy command copies the file from the current drive
to drive a the shift command move the list of parameters one position to the
left and the go to command sends ms-dos back to the label start the label done
marks the end of the batch file let's test the batch file with three
parameters
so we tried to archive p bold q doc and Q old p old was already on dr a so there
wasn't confirmation that the file is copied however q dot doc and q old were
not already there so those two files did get copy next we have a batch file that
demonstrates the for command sometimes you may want ms-dos to carry out a
command more than once in a batch file the for command does just that the for
command has three parameters % % p is a replaceable parameter used inside the
for command ms-dos assigned to the values in set set is the list of values
in the parenthesis here that gets assigned to % % p in this case we've
chosen adventures in nostalgia and the command can be any ms-dos command other
than another for command so for example here we're using the echo command let's
see what this looks like when we execute the batch file
in this case we didn't have at echo offset so it's going to show us each
command as it's executed so the four command echoed the word adventures
echoed the word in and then echoed the word nostalgia then it's finished this
is just an example of how to use the four command you can also use
replaceable parameters for set so instead of adventures in nostalgia we
can use percent one percent two percent three
so now that will echo dog cat and mouse now echo is not the only commands that
can be used with this we can try something a little more practical like
make directory
so that made the directory games apps and data so we can use der / ad which is
the attribute for a directory for D and that's going to show us just the
directories in the current directory where in which is Dave so our for
command created the directories games apps and data for there we go join me
next week for working with the call and choice command thanks for stopping by
see you next video