I have tried to make a batch which searches in a folder for .txt
files and if the text file contains special words, it should write a word before and after this word.
Example:
*.TXT contains:
alpha
beta
rose
delta
The batch should search for rose
and overwrite the text file with:
alpha
beta
before
rose
after
delta
My batch looks at the moment as follows:
@echo off
for %%g in (*.txt) do (
>"temp.txt" (
for /f "usebackq delims=" %%h in ("%%~g") do (
echo before %%h after
)
)
move /y "temp.txt" "%%~g"
)
But I think somewhere is missing an if
function that the text should only be written before/after the word rose
.
Can somebody give me a hint how to proceed?