625

I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions?

0

31 Answers 31

1
2
-6

I have faced this problem several times while coding under Visual C++. If you have it, you can use Visual studio Find and Replace Utility. It allows you to select a folder and replace the contents of any file in that folder with any other text you want.

Under Visual Studio: Edit -> Find and Replace In the opened dialog, select your folder and fill in "Find What" and "Replace With" boxes. Hope this will be helpful.

Sign up to request clarification or add additional context in comments.

3 Comments

Nadjib, your answer doesn't help the user because your assuming they are using software of which they make no mention. Please suggest an option that doesn't require software.
@Aibrean the answer is no use, but not for that reason, it's the entry point that is wrong.
This response does not deserve the downvotes. In a Windows environment, there aren't a lot of good options to solve the OP's problem. I happen to code in VS and found this to be an excellent answer, and saved me a ton of time hunting for another solution. Replaced 20k+ occurrences in over 2k files across 3 directories in less than a min.
1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.