Posted by
Abhishek Pathak
on
Bat Script replaces the whole line in Config file : Count Char :countChar setlocal set x=%1 set n=0 set m=255 :loop if "!x:~%m%,1!" == "" ( set /a "m>>=1" goto loop ) else ( set /a n+=%m%+1 set x=!x:~%m%! set x=!x:~1! if not "!x!" == "" goto loop ) set /a "rtn=%n" exit /b %rtn% call :countChar %usrname% echo the answer is %errorlevel% Replace string GOTO:MAIN :firstMethodName SETLOCAL ENABLEDELAYEDEXPANSION SET seachString=%~1 SET replaceLine=%~2 set finalReplaceLine=%seachString% : %replaceLine% if exist %target% del %target% for /F "delims=" %%a in ('type %source%') do ( set line=%%a echo %%a | find /i "%seachString%" && set line=%finalReplaceLine% cls echo !line! >> %target% ) del Config.txt rename "Output.txt" "Config.txt" ENDLOCAL EXIT /B 0 ...
- Get link
- X
- Other Apps