0

I am trying to achieve to get the output without single quotes.
Please help me if you have any ideas.

Example: The below command I am using to read the test file having strings with enclosed single quotes ''.

I want to display or get the output without single quotes.

for /F "tokens=1" %i in (test.txt) do @echo %i

Current output:

'testonesite'
'testtwosite'
'testhreesite'
'testfoursite'

Expected output like below.

testonesite
testtwosite
testhreesite
testfoursite

2 Answers 2

0

You can replace text in a variable by using this syntax: %value:search=replace%.

In your particular case you would also need to use EnableDelayedExpansion and ! because the variable is processed in a for-loop.

@echo off
setlocal EnableDelayedExpansion

for /F "tokens=1" %%i in (test.txt) do (
    set value=%%i
    echo !value:'=!
)
0

Just try to set this character as your delimiter ':

for /f tokens^=1delims^=' %i in (test.txt)do @echo=%i

... or... 

for /f "tokens=1 delims='" %i in (test.txt)do @echo=%i

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .