batch file - How do I call concat : %variable% when the variable has internal spaces? -


i trying concat variables in class path using following command, isn't working when folder name contains spaces:

call concat : %variable% 

where %variable% ={folder name containing space}

i tried putting quotes:

call concat : "%variable%" 

but adds 2 double-quotes in classpath follows:

""folder name containing space""  :concat set classpath=%classpath%;"%1" 

do not use additional double quotes strings spaces. parameter %~ removes pairs of double quotes around 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:  var 

if put additional double quotes around string, following 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 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -