Page 1 of 1

Insert suffix to every line in TXT file

Posted: 11 Jan 2018 15:08
by aisha
Hello DOS Tips,
We are trying to insert a suffix to the END of EVERY line in a file.

so we are trying to add a quote mark to the end of each line with

setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (c:\sandbox\original.txt) do
set /a N+=1
echo ^"%%a^" ^>c:\sandbox\new.txt

c:\sandbox\original.txt
"Jack and Jill went up the hill
"Jill and Jack went up the hill

c:\sandbox\new.txt
"Jack and Jill went up the hill"
"Jill and Jack went up the hill"

...but there is something wrong with the syntax and my brain is melting.

Help please

Re: Insert suffix to every line in TXT file

Posted: 11 Jan 2018 16:46
by Squashman

Code: Select all

@echo off
(for /f "delims=" %%a in (c:\sandbox\original.txt) do (
    set /a N+=1
    echo %%a"
))>c:\sandbox\new.txt
No idea what you are tying to do with the N variable.

Re: Insert suffix to every line in TXT file

Posted: 11 Jan 2018 21:23
by aisha
thank you so much sir!

Aisha