1. 两个%括起来的变量,说明是用的变量的值,而不是变量本身。
如 set version = "1.0"
echo version //// print verison in console
echo %version% ////print 1.0 in console
2. For parameter %%variable IN fittler DO do something
For has four parameters:
1) /d(only directory, it means this command will work on the direcoty not file),
2) /l(迭代数值范围 Iterative numerical range) for /l %%i in (start#, step#, end#) do command, will execute command when start#<end#.
3) /r(recurrence(递归,遍历), example: for /r c:\ %%i in (*.exe) do @echo %%i )
4) /f (迭代及文件解析)
eol=c - specifies an end of line comment character
(just one)
skip=n - specifies the number of lines to skip at the
beginning of the file.
delims=xxx - specifies a delimiter set. This replaces the
default delimiter set of space and tab.
tokens=x,y,m-n - specifies which tokens from each line are to
be passed to the for body for each iteration.
This will cause additional variable names to
be allocated. The m-n form is a range,
specifying the mth through the nth tokens. If
the last character in the tokens= string is an
asterisk, then an additional variable is
allocated and receives the remaining text on
the line after the last token parsed.
usebackq - specifies that the new semantics are in force,
where a back quoted string is executed as a
command and a single quoted string is a
literal string command and allows the use of
double quotes to quote file names in
file-set.Some examples might help:
FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
%%variable: it may be a-z or A-Z, and it is case sensitive. For will set its value with any what it gets.
IN: syntax
3. %* : it presente the parameter passed by command line. %1 means the firlst one, and %2 means the second one, and so on.
4. Interact with users: Set /p variable= [prompt string]. It is very important that must have a whiteplace after the "=". You can use %variable% get users input value.