How can check if path has quotes or not, and add it if not have? I know i can make something like:
set /p path="My path "
"%path%"
But i have problems with quotes
C:\My folder --> "%path%" --> "C:\My folder" --> Good
If the user put a path with quotes
"C:\My folder" --> "%path%" --> ""C:\My folder"" --> Wrong
I can't use double quotes because the external command line i call not work and give me error. So how i can add "" only if not found in path? Thanks
You can remove quote before using it, try:
set path=%path:"=%
path
has not quote any more.
Example:
@echo off
set path="a b c"
set path=%path:"=%
echo %path%
Output
a b c
for /f "delims=" %%i in ("%var%") do set "var=%%~i"
echo %var%
%var% has no double quotes around after the for loop.
Btw: you should not use cmd commands as batch variables (PATH).
Can't test this as I'm writing from my phone, but can't you just assume there are double quotes and do a find & replace:
set path=%path:""="%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With