- Batch Script Tutorial
- Batch Script - Home
- Batch Script - Overview
- Batch Script - Environment
- Batch Script - Commands
- Batch Script - Files
- Batch Script - Syntax
- Batch Script - Variables
- Batch Script - Comments
- Batch Script - Strings
- Batch Script - Arrays
- Batch Script - Decision Making
- Batch Script - Operators
- Batch Script - DATE & TIME
- Batch Script - Input / Output
- Batch Script - Return Code
- Batch Script - Functions
- Batch Script - Process
- Batch Script - Aliases
- Batch Script - Devices
- Batch Script - Registry
- Batch Script - Network
- Batch Script - Printing
- Batch Script - Debugging
- Batch Script - Logging
- Batch Script Resources
- Batch Script - Quick Guide
- Batch Script - Useful Resources
- Batch Script - Discussion
Batch Script - Empty String
An empty string can be created in DOS Scripting by assigning it no value during it’s initialization as shown in the following example.
Set a=
To check for an existence of an empty string, you need to encompass the variable name in square brackets and also compare it against a value in square brackets as shown in the following example.
[%a%]==[]
The following example shows how an empty string can be created and how to check for the existence of an empty string.
Example
@echo off SET a= SET b=Hello if [%a%]==[] echo "String A is empty" if [%b%]==[] echo "String B is empty "
Output
The above command produces the following output.
String A is empty
batch_script_strings.htm
Advertisements