Multiple find and replace of content using Grep
Posted on December 3, 2008 at 5:35 am
We have posted articles about searching for files and file content using Super Finder and Google Desktop. But what if you have a bunch of files wherein you want to actually replace a content inside them? sure you can use Notepad or any text editor to find and replace content for individual files but this will require you to do this on each of the files.
I have been using Integrated Development Environment (IDEs) tools like Netbeans and Visual Studio to do this for my software development projects but they are too “bloated” for plain text files.
With winGrep, you can do a global search and replace of any string on all files located at your inputted path:
Step 1: In the “Search in” field, enter the directory path.
Step 2: In the “Search for” field, enter the string or regular expression
Step 3: Click “Search” button
You should see the search results on the bottom part of the screen:
The listing has a column with filename, size, matches inside the file, path and encoding type. The “matches” column tells you how many instances of the searched word exists in the file.
To do a search and replace, enter the replacement word in the “Replace with:” field then click “Replace”:
Be careful as this can ruin your files. I usually backup my files before doing a search and replace since a replace will effectively change the content of the files.
To create backup files, make sure to check the “Create backup files” checkbox:
The backup files will be saved on the same folder with a “.bak” extension. This way you can “recover” files by renaming the “.bak” files.
If there are cases wherein you only want to make it search based on a filename pattern or file size, use the “Limit Search” options:
In the example above, I set it to search only for files with a .epj extension. You can change this to any file name extension like .log or .txt.
winGrep, is a powerful tool. Use it with caution because there is no “undo” functionality. Make sure to backup your critical files first before doing a replace. You can get grepWin for free from the Google code website:
http://code.google.com/p/grepwin/downloads/list
Ben Carigtan shows you how it’s done.
» Filed Under Computer Tips
Related Posts
- How to mass rename files using File Renamer Basic
- ALZip, a WinZip alternative
- How to make your own Photoshop patterns
- Combine or merge multiple text files using TXTCollector
- Hide extensions for known file types in Windows Vista






















