Editing a txt file with batch files

June 2, 2009 at 19:07:19
Specs: Windows Vista
So I need to make a batch file to change a single word in a text file. For example, in a file.txt file there are lines, this is a text file
I want to be able to change the word text to awesome.
I hope you understand what im trying to do.
Thanks in advance

See More: Editing a txt file with batch files

Report •

June 2, 2009 at 22:54:42
@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile) do (
set str=%%a
set str=!str:old=new!
echo !str!>> newfile

If at first you don't succeed, you're about average.


Report •

June 3, 2009 at 07:33:35
Awsome thanks, do you think you could explain the code. Im trying to learn this stuff also. But thanks.

Report •

Related Solutions

Ask Question