3

I have an issue in batch programming. I fetch the strings generated by consoles, then the string contains double quotes and I will save that to a variable, like,

"/path/compile" -o source.cpp

And now my problem is, how can I remove this 2 double quotes? I'm not sure how to remove that quotes in the middle of the string.

Please advise

domlao
  • 15,663
  • 34
  • 95
  • 134
  • Check out this solution. http://stackoverflow.com/questions/804646/how-do-you-strip-quotes-out-of-an-echoed-string-in-a-windows-batch-file – Chris Albert Oct 02 '13 at 00:32
  • check this link set widget="a very useful item" set widget set widget=%widget:"=% set widget http://stackoverflow.com/questions/1964192/removing-double-quotes-from-variables-in-batch-file-creates-problems-with-cmd-en – ganesh Dec 30 '15 at 08:04

2 Answers2

9
set a="hello" world
set b=%a:"=%
cure
  • 2,588
  • 1
  • 17
  • 25
5

correct syntax:

set "tempvar="/path/compile" -o source.cpp"
echo %tempvar%
set "tempvar=%tempvar:"=%"
echo %tempvar%
Endoro
  • 37,015
  • 8
  • 50
  • 63