Batch file (.bat file) in% 0,% 1, etc. What is represented
0% means the batch itself.
% 1 refers to the batch file name plus a string separated by spaces.
2 to 9% by analogy%
For example,
There batch aa.txt, bb.txt, cc.txt three text and a name batName.bat D under the root directory, the batch is content
@echo off
start %1
start %3
Open a CMD targeting disc D
D:\>batName aa.txt bb.txt cc.txt
Corresponds to: 0% 1% 2% 3%
Will open aa.txt (it is the first argument, ie 1%) and cc.txt (it is the third argument, ie 3%), but does not open bb.txt, because there are no command batch start% 2 (bb.txt second row so that the second parameter)
% Difference between 2% and to 2
%2
substitutes in the second argument. %~2
substitutes the second argumenty but removes any quote marks:
C:\Temp>type t.cmd
@echo off
echo %%2 is: %2
echo %%~2 is: %~2
C:\Temp>t.cmd first second third
%2 is: second
%~2 is: second
C:\Temp>t.cmd first "second third"
%2 is: "second third"
%~2 is: second third
echo off and echo on the role of
The first to write a batch file, the command is very simple, just print statements, as follows:
I rem " execution OFF echo " and " execute ON echo " is also printed out, right in front of the rem is equivalent to java annotation // echo the first sentence of echo second sentence echo the third sentence echo OFF echo the implementation of echo after OFF echo of an echo of the second sentence echo the third sentence echo oN echo back oN to perform echo echo of the first sentence echo second sentence echo third sentence
Then are the results, there is described in FIG:
The implementation of "echo off", later executed command will not be displayed and will only show results.
But "echo off" command itself will be shown how to do, so that echo off the front to see the general has "@", "@" role is to visit all the commands are not displayed, only perform, and "echo off" similar, but only on the current line of work
————————————————
Disclaimer: This article is the original article CSDN bloggers "S_clifftop", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/S_clifftop/article/details/78632313
Disclaimer: This article is the original article CSDN bloggers "rainbow702", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/rainbow702/article/details/50516739