Editing a specific text on a specific line txt batch -
so title allready says mean okay mean: here have text:
login: demo password: demo world: demo script: demo status: online login: demo password: demo world: demo script: demo status: online login: demo password: demo world: demo script: demo status: online
so want edit batch:
login: demo password: demo world: demo script: demo status: online login: demo password: demo world: demo script: demo status: offline login: demo password: demo world: demo script: demo status: online
and keep text allready posted! i've allready made script creates line's status online! need script can this:
set /p login=please enter login name: set /p status=please enter status: ::here must code change's status echo account status changed!!
thank :)
nevermind made allready!!
here solution:
:start cls @echo off setlocal enabledelayedexpansion set counter=1 /f "delims=" %%x in (accounts.txt) ( set "bot_!counter!=%%x" set /a counter+=1 ) set /a numlines=counter - 1 set countero=1 /f "delims=" %%x in (status.txt) ( set "status_!countero!=%%x" set /a countero+=1 ) /l %%x in (1,1,%numlines%) echo id: %%x !bot_%%x! !status_%%x! endlocal set /p id=bot id: set /p rep=status: @echo off &setlocal set "file=status.txt" set /a line#tosearch=%id% set "replacement=%rep%" (for /f "tokens=1*delims=:" %%a in ('findstr /n "^" "%file%"') ( set "line=%%b" if %%a equ %line#tosearch% set "line=%replacement%" setlocal enabledelayedexpansion echo(!line! endlocal ))>"%file%.new" type "%file%.new" move "%file%.new" "%file%" cls goto start
i've splitted in 2 files. accounts.txt andstatus.txt dont on variable name's because solving issue , not working on nice code :p here have it.
Comments
Post a Comment