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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -