windows - Add chararacter to end of each lines except the last one -


i'm trying convert file containing json line json array. achieve had append opening , closing square brackets file (which done!). finish need append comma end of each line except last one. i'm using following script, don't how stop @ last line.

@echo off setlocal enabledelayedexpansion /f "tokens=* delims= " %%a in (input.txt) ( set /a n+=1 echo ^%%a^, >> output.txt ) 

thank advance help!

try , should work if lines not content ! symbols. produce temp.file .if file need remove last line.you'll need change values of fileloc , endsymbol values want.

@echo off setlocal enabledelayedexpansion  ::-------------------------:: :: change values here  :: set "fileloc=testfile.txt" set "endsymbol=," ::-------------------------::    set counter=0 /f "usebackq tokens=* delims=" %%# in ("%fileloc%") (     set /a counter=counter+1     set "line[!counter!]=%%#" )  set /a uptoline=counter-1 break>temp.file /l %%# in (1;1;!uptoline!) (     (echo(!line[%%#]!%endsymbol%)>>temp.file ) (echo(!line[%counter%]!)>>temp.file  :: uncoment line bellow if temp.file ok rem move /y temp.file "%fileloc%" 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -