I would like to complete the information you have about the possible solutions for this problem.
In this site there is another program similar to Jrepl.bat that allows to replace strings inside text files; it is called FindRepl.bat and you may download it from
this link. These programs are extensive applications with advanced capabilities that can perform this replacement and many more, much more complex ones.
However, the use of anyone of these programs to perform a task as simple as just replace a couple strings from several small files is certainly a waste of resources that may be achieved in much simpler ways. You don't need hundreds of lines of code to do the same thing, just a small Batch-JScript hybrid script specifically written to solve this problem that would be as robust and fast as anyone of Jrepl.bat or FindRepl.bat.
As a matter of fact, the code below should run faster than the proposed Jrepl.bat solution because the program is
much smaller and each data file is processed just one time, that is, the two replacements are completed in the same processing pass instead of process each file one time for each replacement.
Code: Select all
@if (@CodeSection == @Batch) @then
@echo off
for /F "delims=" %%a in ('dir /S /B *.nfo') do (
cscript //nologo //E:JScript "%~F0" < "%%a" > "%%a.new"
move /Y "%%a.new" "%%a"
)
goto :EOF
@end
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/<rating>.*<\/rating>|<votes>.*<\/votes>/g,
function (A){return {rating:"<rating>0</rating>", votes:"<votes>0</votes>"}[A.slice(1,A.indexOf(">"))]}));
As an added bonus, this code is simple enough so you are encouraged to review it, modify it and use it for "what if" testing purposes, something that certainly you can't do with Jrepl.bat or FindRepl.bat original code!
Antonio