]?
For example, the content of test. bat is as follows (NOTE: When determining the return value using if errorlevel, sort the returned values from high to low ):
@ Echo off
Choice/C dimethyl/M "defrag, mem, end"
If errorlevel 3 goto end
If errorlevel 2 goto mem
If errotlevel 1 goto defrag
: Defrag
C:/DOS/defrag
Goto end
: Mem
Mem
Goto end
: End
Echo good bye
After this batch is run, "defrag, mem, end [d, M, E]? ", The user can select d m e, and then t
be called. The file name must use. BAT as the extension.
Batch-ParametersSpecifies the command line information required by the batch processing program.
-------------------------------
Pause
Pause the execution of the batch processing program and display a message prompting you to press any key to continue execution.
start pointer with the first parameter as the Datum.
=================
Special commands
If Goto choice for is a more advanced command in a batch file, you are an expert in batch files if you use them skillfully.
An if is a conditional statement that is used to determine whether a specified condition is met, thus determining the execution of a different command.
% 1% 2% 3% 4% 5% 6% 8Unfortunately, both win9x and DOS do not support shift inverse operations. shift supports the/n parameter only in the nt kernel command line environment. You can use the first parameter as the benchmark to move the start pointer.========================Special commandsIf goto choice for is a relatively advanced command in the batch processing file. if you are familiar with these command
value of the program, different commands are executed based on different return values (the return values must be sorted in ascending order ). If the return value is equal to the specified number, the condition is true. Run the command. Otherwise, run the next sentence.
For example, if errorlevel 2 goto x2
2. When the goto batch processing file runs here, it will jump to the label specified by goto (label,
What are the commands in the batch file?
For the time being, the commands in the batch file can be understood as the DOS command, and will be explained later. batch Processing, as its name implies, is a pile of things heap together for processing. in other words, you c
Batch processing files are indispensable for large-scale project development. Many environment variables are set and the project environment is created. Therefore, I have summarized the syntax of batch processing and used it as a knowledge reserve.
First, the batch file is a
, similar to pointer operations in C. the figure is as follows:Initial status. CMD is the command name and can be referenced with % 0.CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 Arg8 arg9 arg10^|% 0% 1% 2% 3% 4% 5% 6% 7% 9After one shift, CMD cannot be referenced.CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 Arg8 arg9 arg10^|% 0% 1% 2% 3% 4% 5% 6% 7% 9After two shifts, arg1 is also deprecated, and % 9 points to null, with no reference significance.CMD arg1 arg2 arg3 arg4 arg5 arg6 arg7 Arg8 arg9 arg10^|% 0%
First, the batch file is a text file, and each line of the file is a DOS command (most of the time like the command line we execute at the DOS prompt), you can use the DOS edit or Windows Notepad (Notepad) Any text file Editing tool creates and modifies a
1. Introduction to simple batch processing internal commands1. Echo commandEnable or disable the request echo function or display messages. If no parameters exist, the echo command displays the current echo.SyntaxEcho [{on | off}] [Message]Sample: @ echo off/ECHO Hello WorldIn actual application, we will combine this command with the redirection symbol (also known as the pipeline symbol) to implementEnter some commands to a
One, basic format
Executes a specific command on each file in a set of files.
For%variable in (set) do command [Command-parameters]
%variable specifies a single letter replaceable parameter.
(set) to specify one or a set of files. You can use wildcard characters.
command specifies the commands that are executed for each file.
Command-parameters
Specify a parameter or command-line switch for a specifi
This article is from a small piece of software I wrote: Multi-threaded batch probing the type of server for each IP segment of the specified IP (apache,tomcat,iis ... ) and write the probe results to a file. So the question is: how to ensure that multiple threads are used in the loop increment of IP and that each IP is not reused for submission (PS: Of course, to
Bat Batch File Syntax (2)
Batch Processing example:
1. If-exist
1) First, use NotePad to create a test1.bat batch file in C:/. The content of the file is as follows:@ Echo offIf exist/a
you can move the start pointer with the first parameter as the base.=================Special commandsIf Goto choice for is a more advanced command in a batch file, you are the expert on batch files if you use them skillfully.If is a conditional statement used to determine whether the conditions are met, thus deciding to execute different commands. There are thre
may be used: ECHO, set, set/P, % date %, % ~ >,>>
Summary and tips:The actual usage of the for command has basically ended. However, this command cannot write batch processing with powerful functions. It is just a doscommand, you need to be familiar with some other DOS commands and the commands provided by Windows systems, and use them in combination to make full use of their powerful and practical functions, so that some complicated things can be pr
To write a program that imports data in batches, learn to write shell scripts! Now learn to use!============================================1, the first simple for loop#!/bin/bashFor I in 1 2 3 4;Doecho $i;Done2. Test for self-growing loops:#!/bin/bashfor ((I=1; iDoecho $i;DoneIf there is an error, no then skip:Syntax Error:bad for loop variableReason: The code is not wrong for standard bash, because Ubuntu
characters in the in (set)1) in (set) no wildcard charactersSpecifies a single file or enumeration of specific files (multiple file names separated by delimiters, such as spaces, commas, etc.)Example 2
@echo of
for/r.%i in (abc.txt) doing echo. >%i
echo on
Note: There is only one path after the for/r. And the echo in each loop behind it. >%i is equi
author! I searched the internet again just now and found that this tutorial was reposted everywhere. I could not find the author or original source! Thanks to this unknown expert!-- TTT 200906160033++Format: For [parameter] % variable name in (related file or command) Command executed by doPurpose: execute specific commands on each object in one or more files, strings, or command results to achieve the desired results.Note: when using the for command
I haven't written a blog for a long time. I haven't read much about it in this period of time, but I always feel that I have not finished a job. So I will write down my summary.Section 1 describes windows batch processing.This is because I learned how to work in windows with my colleagues. I gradually needed some batch processing functions, so I took a few days to study it. I think the most important featur
Format: for [parameter]% variable name in (related file or command) do execution command
Function: Executes specific commands on one or a set of files, strings, or on each object in the result of a command to achieve the desired result.Note: When using the for command in a batch file, use%%variable instead of%variable when you specify the variable. Variable name
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.