batch file - Find and replace string between two documents (more times) -


i new @ programming , wanna make .bat script, take first string new.txtand find in text.txt, replace second string new.txt (there more 1 exact string in text.txt, script must search whole document).

and then, after search whole document, script take new.txt third string, find in text.txt , replace fourth string new.txt, find fifth string new.txt , replace sixth string etc.

i hope it, because english isn´t :-) everyone.

here examples documents, if helps:

text.txt:

ale ne, ne, ne! try tape slot, maybe it's in there. try tape slot, maybe it's in there. hey now… hey now… you, "sheriff"? next time i'm gonna have charge you. blablabla. vsadil bych se, ze je tohle skvele misto pro veci, ktere nechces, aby nekdo videl. nevedel bych. byl tady uz kdy jsme se pristehovali, nemam k nemu klic. blablabla. 

new.txt:

blablabla. blbblbblb. ale ne, ne, ne! no, no, no! try tape slot, maybe it's in there. zkus packu, mozna bude tam. 

this works here, except lines contain ! characters.

this uses helper batch file called repl.bat - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

place repl.bat in same folder batch file or in folder on path.

@echo off set "file=text.txt" set "line=" setlocal enabledelayedexpansion /f "delims=" %%a in (new.txt) (    if not defined line set "line=%%a"       if not "!line!"=="%%a" (          type "%file%" |repl "!line!" "%%a" l >temp.txt          move temp.txt "%file%" >nul          set "line="       ) ) 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -