Certainly! Here are some common formulae and functions related to batch scripting:
For Loop(对于循环):
for /L %%variable in (start,step,end) do commandfor /L %%i in (1,1,10) do echo %%iIF Statement(IF语句):
if condition (command) else (command)if exist file.txt (echo File exists) else (echo File does not exist)Variable Assignment(变量赋值):
set variable=valueset myVar=HelloCommand Line Arguments(命令行参数):
%1, %2, ...echo The first argument is %1GOTO Statement(GOTO声明):
goto labelgoto startFunctions (using call)(函数,用于调用):
Formula: call :functionName arg1 arg2 ...
Example:Call it: call :myFunction
:myFunction
echo This is a function
exit /b
String Manipulation(字符串操作):
%variable:~start,length%set myString=HelloWorld then %myString:~0,5% gives HelloThese are some fundamental elements of batch scripting. Let's practice by using these in a sentence: