Insert suffix to every line in TXT file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aisha
Posts: 26
Joined: 28 Sep 2016 06:40

Insert suffix to every line in TXT file

#1 Post by aisha » 11 Jan 2018 15:08

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

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Insert suffix to every line in TXT file

#2 Post by Squashman » 11 Jan 2018 16:46

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.

aisha
Posts: 26
Joined: 28 Sep 2016 06:40

Re: Insert suffix to every line in TXT file

#3 Post by aisha » 11 Jan 2018 21:23

thank you so much sir!

Aisha

Post Reply