Simple replace text in txt file script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Pieceinc
Posts: 2
Joined: 09 Apr 2021 03:24

Simple replace text in txt file script

#1 Post by Pieceinc » 09 Apr 2021 03:31

Gday guys. I’ve been searching through the forums and there’s lots of answers that seem way more complicated than what I need

All I need is a bat file I can run to change the current 1 line of text in a txt file to something else

Eg sample.txt just has this is it:
Ivory

I need a batch file that when I run it it changes the text to another colour and saves the file

My plan is to have multiple bats with different colours so it just needs to replace whatever is currently there to the new thing. The reason I’m doing it that way doesn’t really matter

Thanks in advance!

miskox
Posts: 396
Joined: 28 Jun 2010 03:46

Re: Simple replace text in txt file script

#2 Post by miskox » 09 Apr 2021 06:44

If you only have one line (you wrote: sample.txt just has this in it) in the file you could only use

Code: Select all

@echo new_color>filename.txt
Answer is based on the info you provided.

Saso

Pieceinc
Posts: 2
Joined: 09 Apr 2021 03:24

Re: Simple replace text in txt file script

#3 Post by Pieceinc » 12 Apr 2021 04:43

Yep thats all i need. Thanks

Post Reply