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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
PiotrMP006
Posts: 31
Joined: 08 Sep 2017 06:10

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

#1 Post by PiotrMP006 » 28 Sep 2020 03:05

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

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

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

#2 Post by elzooilogico » 28 Sep 2020 03:34

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

Post Reply