Batch Script - String length Last Updated : 04 Jan, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article , we are going to learn how to find length of any String using Batch Script. Batch Script :@echo off set str=Geeks For Geeks call :strLen str strlen echo String is %strlen% characters long pause exit /b :strLen setlocal enabledelayedexpansion :strLen_Loop if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop (endlocal & set %2=%len%) goto :eof In Batch Scripting there no function for checking length of string ,So we will create a function to find length of string. Explanation :By using ' set ' we are getting our input string whose length is to calculated.In above code we are creating a Function "strLen" , which we can use to find our string length.From ':strLen' our function is started , then we will initialize our Loop with 'strLen_Loop'.("!%1:~%len%!") this statement is checking that our string is ended or not by using (=="").if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_LoopDuring execution of our 'if' statement its checking if ("!%1:~%len%!"=="") this argument is True then it will Break the Loop and if its False , it will be continued.Now if our argument is False then we will set our 'len' variable as 'len=len+1' (also written as len+=1).By using 'goto :strLen_Loop' we are continuing our Loop.Now , again it will check whether our string is ended or not by using command ("!%1:~%len%!"=="") and increase 'len' by 1 if argument is False.Now let's assume when our argument is True , loop will break and our string length is set in 'strlen'.When 'strlen' is called it will print our string length. Output: Comment More infoAdvertise with us Next Article Batch Script - String length T thenavneet Follow Improve Article Tags : Linux-Unix Batch-script Similar Reads Batch Script - Left String In this article, we are going to study Left string in Batch Script. In Batch Script, the Left string is used to extract the characters from the beginning of the string by giving position 0 and a length using:~ while expanding a variable content. Example 1: Batch script set str=GeeksForGeeks echo.%st 1 min read Batch Script - Right String In this article, we are going to learn how to use the concept of Right String using Batch Script. Right String uses the concept of negative indexing. We have to extract the characters using :~ followed by the negative index of the character from which we want to print a substring from the main strin 2 min read Batch Script - Empty String In this article, we are going to create an Empty String using Batch Script. Batch Script :@echo off set str1= set str2=Hello ::using if statement we will check that str1 is empty string or not. if [%str1%]==[] echo "str1 is an empty string" if [%str2%]==[] echo "str2 is an empty string" pauseExplana 1 min read Batch Script - Create String In this article, we are going to learn how to create a String using Batch Script. Batch Script :@echo off set str=Geeks for Geeks echo %str% pauseBy using ' set ' we are getting input of any string.Ex: set str=input stringIn the next line, we are using ' echo %str% ' for printing our input string.Th 1 min read Batch Script - Strings A Bash script is a plain text file. This file contains different commands for step-by-step execution. These commands can be written directly into the command line but from a re-usability perceptive it is useful to store all of the inter-related commands for a specific task in a single file. We can u 4 min read Like