Page 1 of 1

How to remove Quotes from a variable with "ampersand" (&) ?

Posted: 28 Sep 2020 03:05
by PiotrMP006
How to remove Quotes from a variable with "ampersand" (&) ?

ex

setlocal disabledelayedexpansion

set dir="D:\Test ! & Test\"

set dir=%dir:"=%

after

echo %dir%

D:\Test ! Test\

Sign & is missing !!!!

Please help

Re: How to remove Quotes from a variable with "ampersand" (&) ?

Posted: 28 Sep 2020 03:34
by elzooilogico
you can use a for loop to remove quotes with the ~ modifier. see for /? for further information.

Code: Select all

for %%a in (%dir%) do echo %%~a