Page 1 of 1

Simple replace text in txt file script

Posted: 09 Apr 2021 03:31
by Pieceinc
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!

Re: Simple replace text in txt file script

Posted: 09 Apr 2021 06:44
by miskox
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

Re: Simple replace text in txt file script

Posted: 12 Apr 2021 04:43
by Pieceinc
Yep thats all i need. Thanks