What is the easiest way to find and replace text in 20 text files in a directory?

17

3

I have 20 text files with various extensions in a directory.

I want to replace "nnn" with "ooo" in all files.

I could import them into a project in Eclipse or Visual Studio to replace them all but that is overkill and would add other meta files etc.

What is a simple way to do this, I'm thinking: select all files, right click, choose some tool called (e.g. "QuickReplacer") and fill in find and replace, click and done.

Does anyone know of a tool like this?

Edward Tanguay

Posted 2009-07-31T11:51:24.647

Reputation: 11 955

1I'd like to point out that if you're already using Eclipse, bringing up the Find in Files (or whatever it's called) you can choose a Directory, rather than an existing project, to search. It shouldn't be hard from there to then run a find/replace on matched files. – anonymous coward – 2009-07-31T13:58:56.020

Answers

8

GrepWin would do this among others, and it is a Explorer plugin.

However there is quite a big array of different applications available that can do this.

This SO thread on the topic also suggest WinGrep as an option.

BinaryMisfit

Posted 2009-07-31T11:51:24.647

Reputation: 19 955

installed it and did my search/replace within 3 minutes, thanks! – Edward Tanguay – 2009-07-31T12:02:34.683

19

Notepad++ can do it easily...

Search menu > Find in files.. menu item...

spinodal

Posted 2009-07-31T11:51:24.647

Reputation: 1 293

4

If you are familiar with Visual Studio, you can do that without creating a project. Do (something like): Edit>Find/Replace>Find in Files. There you can specify a folder.

I've done this many times. I'd say it's only overkill if you had to create a project (you don't) or if you didn't have VS installed and needed it only for this request.

Michael Haren

Posted 2009-07-31T11:51:24.647

Reputation: 729

2

I find that Textpad is very useful for this kind of thing, amongst others.

Remou

Posted 2009-07-31T11:51:24.647

Reputation: 298

1

Sublime: Ctrl+Shift+f

Replaces text in all open files, or you can specify particular folder(s) by clicking .

Afterwards, hit File > Save All.

Dunc

Posted 2009-07-31T11:51:24.647

Reputation: 243

0

I really like the WildEdit product by Helios Software (makers of the excellent Textpad text editor).

It's reliable, quick, flexible, and doesn't cost much (£8.50 = approx. 10 Euro) - well worth its price!

It handles ASCII, ANSI, UTF-8 and other encoding with no problem, you can pick a directory and a file mask (*.cs, *.as?x etc.) and apply the changes only to those files, and it will keep a backup of your original files in case you want to undo the change.

Marc

marc_s

Posted 2009-07-31T11:51:24.647

Reputation: 1 408

0

SciTE has this built in on Windows - so long as all the files are in the same directory (and is a very small and quick general purpose text editor into the bargain) - right click and 'Edit with SciTE' any one file in the directory, Ctrl+Shift+F, type in search and replace strings and an optional filename filter and click OK.

robertc

Posted 2009-07-31T11:51:24.647

Reputation: 729

-1

I know I'm a bit late to the Party, Just wanted to Mention this great free tool. http://dngrep.github.io/

Pola Edward

Posted 2009-07-31T11:51:24.647

Reputation: 99