Computer Hope
Microsoft => Microsoft DOS => Topic started by: xabiy on October 06, 2008, 03:36:43 AM
-
Hello,
I have a TexRep software from No Nonsense Software. I can make my changes singly.
I'ld like to make my changes automatically. It means, there are several .htm files in a folder and need to change text parts in this files. How can I do it with FOR command in a batch file?
e.g:
texrep *.htm "texttofind" "replacewith"
Sorry if it is an resolved issue but I couldn't find.
Thanks,
Csaba
-
Text files cannot be updated in place with batch code. This little snippet produces output files with a chg extension.
@echo off
setlocal enabledelayedexpansion
set /p search=Search String=
set /p replace=Replace With=
for %%v in (*.htm) do (
for /f "tokens=*" %%a in (%%v) do (
set newline=%%a
set newline=!newline:%search%=%replace%!
echo !newline! >> %%~nv.chg
)
)
If not run from the htm directory, you may have to add paths to the code.
Good luck. 8)
-
Text files cannot be updated in place with batch code.
You can produce a new file which contains the changed text, delete the original file, then rename the new file with the original name.