I need to create a single string variable by concatenating multiple strings. The final string i need is as below
<Workspace name="RealTimeRiskUSD_UA" path="C:\workspace" IsAdmin="false" />
This is what i tried.
echo off
set path1="<Workspace "
set name="name="RealTimeRiskUSD_UA""
set path2="path="C:\workspace" IsAdmin="false" />"
set fullpath=%path1%%name%%path2%
echo %path1%
echo %name%
echo %path2%
echo %fullpath%
I also tried using the below link to remove the double quotes from each string but does not work
http://ss64.com/nt/syntax-esc.html
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
So %%k refers to the value of the 3rd token, which is what is returned.
When creating batch files, you can use set to create variables, and then use them in the same way that you would use the numbered variables %0 through %9. You can also use the variables %0 through %9 as input for set. If you call a variable value from a batch file, enclose the value with percent signs (%).
There are two types of variables in batch files. One is for parameters which can be passed when the batch file is called and the other is done via the set command.
You could use the extended syntax of SET. set "var=content".
This escapes special characters, but the quotes aren't part of the string.
echo off
Setlocal EnableDelayedExpansion
set "path1=<Workspace "
set "name=name="RealTimeRiskUSD_UA""
set "path2=path="C:\workspace" IsAdmin="false" />"
set "fullpath=%path1%%name%%path2%"
echo !fullpath!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With