I am trying to concat variables in my class path using the following command, but it isn't working when the folder name contains spaces:
call concat : %variable%
where %variable% ={folder name containing space}
I tried putting quotes:
call concat : "%variable%"
but this adds 2 double-quotes in my classpath as follows:
""folder name containing space""
:concat
set CLASSPATH=%CLASSPATH%;"%1"
                In JavaScript, we can assign strings to a variable and use concatenation to combine the variable to another string. To concatenate a string, you add a plus sign+ between the strings or string variables you want to connect.
In PowerShell, string concatenation is primarily achieved by using the “+” operator. There are also other ways like enclosing the strings inside double quotes, using a join operator, or using the -f operator. $str1="My name is vignesh."
Concatenating in SPSS is done by the CONCAT function. The most basic usage is COMPUTE A = CONCAT(B,C,D) . Note that you can concatenate only strings. For concatenating numbers, first convert them to strings, for example by using the stringfunction.
Put quotes around the entire SET statement:
SET "FOO=AB C"
SET "BAR=%FOO%D EF"
echo %BAR%
Outputs:
AB CD EF
                        Do not use additional double quotes for strings with spaces. The parameter %~ removes all pairs of double quotes around the string:
@echo off &setlocal
set "Variable="my var""
echo Variable:  %Variable%
call :concat %Variable%
goto :eof
:concat
echo concat %%1:    %1
set "NewVar=%~1"
echo concat NewVar: %newvar%
goto :eof
endlocal
Output is:
Variable:       "my var" 
concat %1:      "my var" 
concat NewVar:  my var
If you put additional double quotes around the string, the following will happen:
@echo off &setlocal
set "Variable="my var""
echo Variable:  %Variable%
call :concat "%Variable%"
goto :eof
:concat
echo concat %%1:    %1
set "NewVar=%~1"
echo concat NewVar: %newvar%
goto :eof
endlocal
With broken output:
Variable:       "my var"
concat %1:      ""my
concat NewVar:  "my
                        remove the double quote from input, use double quote around the entire set, when use the concatenated string, surrounding them by double quote, for example:
set root=%~1
@echo off
setlocal EnableDelayedExpansion
set i=0
for %%d in (
1.07 1.023 1.075 1.08 1.04
) do (
   set /A i=i+1
   set scale[!i!]=%%d
)
set i=0
for %%d in (
CO DE MH PL Pr
) do (
   set /A i=i+1
   set port[!i!]=%%d
)
for %%A in (0 1 2 3 4) do (
set "file1=%root%\Event\Events.txt"
set "file2=%root%\Port E\PortE_!port[%%A]!.txt"
set "file3=%root%\Poli E By Port\E_!port[%%A]!.txt"
%0\..\average101v2.exe "!file1!" "!file2!" "!file3!" !scale[%%A]!
)
                        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