Computing.Net > Forums > Programming > Editing a txt file with batch files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Editing a txt file with batch files

Reply to Message Icon

Name: Termanalor117
Date: June 2, 2009 at 19:07:19 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 2, 2009 at 22:54:42 Pacific
Reply:

@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.

M2


0

Response Number 2
Name: Termanalor117
Date: June 3, 2009 at 07:33:35 Pacific
Reply:

Awsome thanks, do you think you could explain the code. Im trying to learn this stuff also. But thanks.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Editing a txt file with batch files

batch to edit a txt file www.computing.net/answers/programming/batch-to-edit-a-txt-file/15327.html

Editing a txt file, renaming files www.computing.net/answers/programming/editing-a-txt-file-renaming-files/16242.html

editing a txt file using cdm www.computing.net/answers/programming/editing-a-txt-file-using-cdm-/18589.html