If you have a batch file that takes two parameters with quotes around them, and you concatenate them together, you get too many quotes. For example, if you have “test.bat” file with this code in it:
Echo %1%2
And you run it like this:
Test.bat “C:\” “Program Files\”
You end up with this result
“C:\””Program Files\”
Which is not a valid folder. I’m trying to get this result:
“C:\Program Files\”
The problem is, I have to put quotes around both parameters on the command line, in case there are spaces in the folder names. The solution to this is to use a ~ character in the variable, like this:
Echo %~1%~2
Running that command in the test.bat file produces this result:
C:\Program Files\
More info and parsing capabilities can be found here:
DOS - String Manipulation
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.