LABEL: Creates, changes, or deletes the volume label of a disk.


... The examples for the command "LABEL"
... "LABEL" Excerpt from Microsoft Windows Help
... Important information, tips for the "LABEL" command

The command: "LABEL" is on Windows 11, 10, .. available

The examples for the command "LABEL"

The `LABEL` command is used in batch scripts to label a point in the code with a specific name. Here are some examples: Example 1: Simple label:

@ECHO OFF
GOTO start

:Begin
ECHO The script has begun.
GOTO end

:End
ECHO The script is finished.

Description: Shown here is a simple script that uses two labels (`:Start` and `:End`). The script starts at `:Start` and then jumps to `:End`. You can also use `GOTO :End`. Example 2: Use with IF statement:

@ECHO OFF
SET option=YES

IF "%Option%"=="YES" (
    GOTO YesOption
) ELSE (
    GOTO No option
)

:YesOption
ECHO The option is activated.
GOTO end

:No option
ECHO The option is disabled.
GOTO end

:End
ECHO The script is finished.

Description: Here a label is combined with an IF statement. Depending on the variable `Option` it jumps to either `:YesOption` or `:NoOption`. Example 3: Use with FOR loop:

@ECHO OFF
FOR %%G IN (1 2 3) DO (
    ECHO loop pass no. %%G
    GOTO loop end
)

:End of loop
ECHO The FOR loop has ended.

Description: Here a label is used within a FOR loop. After the first loop run, it jumps to `:LoopEnde` and ends the loop early. Example 4: Use with :EOF (end of script):

@ECHO OFF
GOTO main program

:Secondary program
ECHO The secondary program is executed.
GOTO :EOF

:Main program
ECHO The main program starts.
GOTO subprogram

Description: Here a label called `:EOF` (End of File) is used to end the script. When `GOTO :EOF` is reached, the script exits. Example 5: Use with CALL for subprograms:

@ECHO OFF
CALL :Subprogram
ECHO The main program continues.
GOTO end

:Subprogram
ECHO The subprogram is executed.
GOTO :EOF

:End
ECHO The script is finished.

Description: Here `CALL` is used to call a subprogram with a label (`:subprogram`). After the call, the main program returns and continues its execution. Labels are useful for controlling the flow of batch scripts and organizing parts of the code. Note that labels start with a colon (`:`) followed by a name (without spaces). The `GOTO` statement is used to jump to a specific label.

"LABEL" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Creates, changes, or deletes the volume label of a disk.

LABEL [drive:][label]
LABEL [/MP] [volume] [label]

  drive:          Specifies the drive letter of a drive.
  label           Specifies the label of the volume.
  /MP             Specifies that the volume should be treated as a
                  mount point or volume name.
  volume          Specifies the drive letter (followed by a colon),
                  mount point, or volume name.  If volume name is specified,
                  the /MP flag is unnecessary.

Important information, tips for the "LABEL" command

There are a few important points to note when using `LABEL` in batch scripts: 1. Colon: A `LABEL` always begins with a colon (`:`) followed by a name. For example: `:MyLabel`. Note that there can be no spaces before the colon. 2. Case sensitivity: In batch scripts, case sensitivity is usually not relevant. The label `:MyLabel` is equivalent to `:mylabel`. However, it is advisable to maintain consistent spelling to avoid confusion. 3. Uniqueity: Labels must be unique in the script. Two labels with the same name could result in unexpected behavior. It is recommended to choose clear and descriptive names for labels. 4. Use with `GOTO`: Labels are often used with the `GOTO` statement to control script flow. Note that `GOTO` jumps to a label in the same batch script. 5. Labels with `CALL`: You can use `CALL` to jump to a label, especially if it is a subprogram. For example: `CALL :subprogram`. 6. Use with `:EOF`: `:EOF` is used as a special label at the end of a script to terminate the script. When `GOTO :EOF` is reached, the script exits execution. 7. Context Switch: When you jump to a label, a context switch occurs. This means that local variables are available within the label, while variables outside the label are not visible unless they are defined globally. 8. Labels and Loops: Labels can be used in conjunction with loops (`FOR` or `WHILE` loops) to control the flow of the script. 9. Readability: Use labels to divide the code into logical sections and improve the readability of the script. This makes the code easier to understand and maintain. 10. Structured Programming: The use of labels makes it possible to design batch scripts according to the principles of structured programming. This makes maintenance and troubleshooting easier. It is important to consider the above points to ensure that labels are used correctly and effectively in batch scripts. A cleanly structured script makes error diagnosis and maintenance easier.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command LABEL - Creates, changes, or deletes the volume label of a disk.

HTTP: ... console/en/039.htm
0.155
15603

So many folders in the directory tree in Windows 10 Explorer, why?

For what please these energy efficiency improvements for MS Windows OS?

Easier positioning of documents in the PDF by dragging and dropping!

How do I use the download options and the standby blocking?

Set Countdown Timer and use Stopwatches in Windows 10 / 11, can I?

Wie kann ich die nicht wieder beschreibbaren CDs, oder DVDs sicher löschen?



(0)