Example, I have a text file and the contents are:
Dog is a pet.
Dog has four legs.
Dog has tail.
Dog has two eyes.
How do I write a batch file that will remove word “Dog” but it will not remove whole line.
Out put should be:
is a pet.
has four legs.
has tail.
has two eyes.
Thanks!!!
The script requires a good knoledge of batch theory, so try
– for /?
– set /?
I am not a script pusher, so as Derek suggested:
STUDY STUDY STUDY STUDY … don’t waste your time.
@echo off & setlocal EnableDelayedExpansion set /P _file=Enter filename^> set /P _word1=Enter the word to be canceled or replaced^> set /P _word2=Type the word for replacement or press Enter^> type nul > "%_file%.tmp" for /F "delims=" %%i in ('type "%_file%"') do ( set row=%%i set row=!row:%_word1%=%_word2%! echo.!row! ) >> "%_file%.tmp" move "%_file%.tmp" "%_file%"message edited by IVO