Batch Script - Right String Last Updated : 04 Jan, 2022 Comments Improve Suggest changes Like Article Like Report 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 string. Using the right string we can print characters from the right side of any given string. Batch Script :@echo off set str=Geeks for Geeks echo %str% set str=%str:~-5% echo %str% pause Using the above code we are going to print a substring from -5 to -1 index from the given string(i.e. Geeks for Geeks). Explanation:By using ' set ' we are getting input of any stringIn the next line using ' echo %str% ' we are printing our string.Now in the next line using indexing we are going to eliminate characters from the right end. When we are taking the index from the right side, it starts from "-1" and increases by 1 as we move further from right to left.General representation - set str=%string:~right index% . For example, If we are giving the right index as -5, so the string from '-5' to '-1' will be printed.Then we are using 'pause', to hold the screen until any key is pressed, so that we can read our output.Another Approach :Batch Script :@echo off set str=GFG is best platform for Geeks echo %str% :: 10 characters from right will be printed set str=%str:~-10% echo %str% pause In this example, we have given the index value as '-10' which means a substring having 10 characters from the right side will be extracted and printed. Output: As we can clearly see that a substring of 10 characters from the right is printed as output. Comment More infoAdvertise with us Next Article Batch Script - Right String thenavneet Follow Improve Article Tags : Linux-Unix Batch-script Similar Reads Batch Script - Mid String In this article , we are going to learn how to use the concept of Mid String using Batch Script. Using the concept of 'Mid String' we are extracting out a sub string between two indices of any given string. Batch Script :@echo off set str=GeeksforGeeks echo %str% set str=%str:~5,-5% echo %str% pause 2 min read 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 - String length 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 2 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 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 - Replace a String In this article, we are going to Replace a substring with any given string. Batch Script :@echo off set str=GFG is the platform for geeks. echo %str% set str=%str:the=best% echo %str% pause In the above example, we are going to replace 'the' by substring 'best' using %str:the=best% statement. Explan 2 min read Batch Script - String Interpolation String interpolation is a technical way of saying parsing a value that might be a variable into a string. It is an important part of dealing with the application that contains texts in some way to make them dynamic and programmatic. In batch scripting, we can perform string interpolation as well as 2 min read Batch Script - toInt In the Batch script, every variable is considered as a string and optionally integers. We need numbers all the time especially when it comes to performing system operations. We might extract numbers from a string variable but performing operations on them are not the same and require some additional 3 min read Bash Scripting - String Bash String is a data type similar to integer or boolean. It is generally used to represent text. It is a string of characters that may also contain numbers enclosed within double or single quotes. Example: "geeksforgeeks", "Geeks for Geeks" or "23690" are strings Creating a String A basic declarati 2 min read Like