This tutorial explains about batch strings in bath programming

String is collection of characters and assigned to an variable. Example string is hello

How to declare an variable of string

In this, let’s declare an variable and assign value to it.

set str=hello
echo %str%

The output will be hello

In this example, variable str is defined with set keyword and assigned an string to it.

Variable value is printed using %variable%.

Let’s see some examples using an string

String concatenate exmaple

@echo off
set str1=hello
set str2= world
set result= %str1% %str2%

echo Result is %result%

two variables are declare assigned variables.

Appened using % and assign the result Print the result using echo

Length of an string

string length is number of characters in it.