What is the easiest way to find and replace text in 20 text files in a directory?
Solution 1
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.
Solution 2
Notepad++ can do it easily...
Search
menu → Find in Files...
menu item.
In Notepad++ 7.9.2
Go to
File
→ Open Containing Folder
→ Folder as Workspcae
Right click on your folder and select Find in Files...
In Find in Files
dialog, click on tab Find in Files
and fill your keyword in Find what
then fill the replacement in Replace with
and click on Find All button to find all occurrences keyword in all files, or Replace in Files button, to replace all occurrences of keyword with its replacement.
Solution 3
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.
Solution 4
I find that Textpad is very useful for this kind of thing, amongst others.
Solution 5
Sublime: Ctrl+Shift+f
Replaces text in all open files, or you can specify particular folder(s) by clicking …
.
Afterwards, hit File
> Save All
.
Related videos on Youtube
Benoit
web/software developer, .NET, C#, WPF, PHP, have philosophy degree, love languages, run marathons my tweets: http://www.twitter.com/edward_tanguay my runs: http://www.tanguay.info/run my code: http://www.tanguay.info/web my training videos: http://partner.video2brain.com/edwardtanguay
Updated on September 17, 2022Comments
-
Benoit almost 2 years
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
orVisual 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?
-
anonymous coward almost 15 yearsI'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.
-
-
Benoit almost 15 yearsinstalled it and did my search/replace within 3 minutes, thanks!
-
Sergio Prats over 3 yearsThank you! This is a very useful tool, it will help me to save a lot of time!