Archive for April 2011
Removing Quotes from Quoted Strings in Windows batch (or .cmd)
Passing strings between batch files or called routines means they inevitably have to be enclosed in double quote marks (e.g. “String to pass” ) if they are required in one variable.
Once the receiver gets hold of the string and tries to embed it in another string the quotes must be removed.
This simple approach comes from: http://ss64.com/nt/syntax-esc.html.
:: Remove quotes SET _string=###%_string%### SET _string=%_string:"###=% SET _string=%_string:###"=% SET _string=%_string:###=%
The above will only work for non-null strings. There is a link at the site for a more detailed solution.
Avoid using solutions involving %1 %2 %3 etc as they eliminate double spaces.