What do you do if you have to replace a single word in dozens, or even hundreds or thousands, of text files? You keep calm and download Notepad++ or Replace Text [No Longer Available]. These two utilities will do the job in seconds.
It’s a dilemma common among developers and programmers. Imagine you’re managing a project with hundreds or thousands of files. When a product name that appears on almost every page changes, you can hardly go through each page to manually search and change the name. No, you’re smarter than that.
You fire up Google, you find this article, and you learn about a solution that only takes seconds.
How to Edit Multiple Files in Bulk
You can either use Notepad++ or a dedicated tool called Replace Text to bulk-edit your files.
First, allow Notepad++ to find the word in all the files you need to edit. Open Notepad++ and go to Search > Find in Files… or press CTRL+SHIFT+F. This opes the Find in Files menu.
Under Find what:, enter the word or phrase that you need to change. Under Replace with:, enter the new word or phrase. Finally, set the Directory: where the affected files are located, so that Notepad++ knows where to search.
You can also use advanced settings, which I’ve outlined further down. When all is set, click Find All if you need to double-check the hits or Replace in Files if you want Notepad++ to immediately apply the changes. Depending on the number of files Notepad++ is searching, this can take a few seconds.
If you went with Find All, you’ll get a list of hits. Remove all the files you don’t want to edit by selecting them and pressing DEL, then right-click the remaining files and choose Open all.
Now go to Search > Replace or press CTRL+H, which will launch the Replace menu. Here you’ll find an option to Replace All in All Opened Documents.
Again, you can make several advanced settings, as explained below.
Advanced Search and Replace Settings in Notepad++
Under Find in Files, you can add Filters to search only in certain file types. For example, add *.doc to search only in DOC files. Likewise, you can search for files with a certain name, regardless of file type. Add *.* to search any file name and type.
When you choose a directory with sub-folders, check In all sub-folders and In hidden folders to search those, too. You might also want to check Match whole word only, so you don’t accidentally edit a partial match.
The Search Mode in both the Find in Files and Replace menus allows you to make advanced searches and replacements. Select Extended if you are using extensions, for example to replace a character with a new line (\n). Select Regular expression if you’re using operators to find and replace all matching words or phrases. You can stick with Normal if you’re just replacing text with text.
Replace Text [No Longer Available]
With Replace Text, you can set up a Replace Group to add multiple files and/or directories and multiple replacements.
To start, create a new group. Go to Replace > Add Group, and give your group a name.
Right-click your group and select Add File(s)… to add the files and/or folders you want to edit. In the Files / Folder Properties, select your Source Type, i.e., a single file or folder, then choose the Source File / Folder Path. If you choose to add a folder, you can also include and exclude file types by adding them to the Include File Filter or Exclude File Filter rows. Click OK when you’re done.
To add multiple files or folders, repeat the above step.
Replace Text’s best feature is that you can choose a destination that’s different from the original location. In the File / Folder Properties, switch to the Destination tab and choose your desired Destination File / Folder Path.
Now that you’ve set up your group, it’s time to define your replacements. Select your group and go to Replace > Search/Replace Grid > Advanced Edit… Now you can add the Search Text and Replace Text. Be sure to look in the drop-down menu at the bottom to customize the search and replace options.
Like with Notepad++, you can use advanced search strings and operators . Unlike Notepad++, you can add as many search and replace instances as you like and Replace Text will run through all of them when you run the process.
To make the replacements, go to Replace > Start Replacing or press CTRL+R.
About the Tools
What Is Notepad++?
Furthermore, Notepad++ is a lightweight application that conserves resources, which makes it good for the environment:
By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.
Here’s a small selection of Notepad++ features that make this the perfect tool for writing and editing (code):
Numbered lines for easier navigation.
Automatic and customizable highlighting and folding of coding syntax.
Support for Perl Compatible Regular Expression (PCRE) search-and-replace.
Auto-completion that includes word completion, function completion, and function parameters hint.
A tabbed interface that lets you work with multiple documents in parallel.
Editing of multiple lines at once, using either CTRL+mouse-selection or column editing.
What Is Replace Text?
Replace Text is a whole lot simpler than Notepad++. It does one job: replacing text. Ecobyte, the company behind Replace Text, is mindful of its impact. Hence, the software with a cause comes with an unusual EULA:
Unfortunately, Replace Text is no longer supported and no help file is available in Windows 10. I have covered it anyhow because it offers more advanced features than Notepad++ for this particular application.
Search and Replace Made Easy
One of the two utilities above should do the job for you. If you only have a simple search-and-replace job or if the additional features of Notepad++ sound useful, you should give it a try. If you need to edit not only multiple files , but also need to make multiple different replacements, it’s worth looking into Replace Text.
Which one did you choose and did it work as prescribed? Have you found other tools that can search-and-replace text? Let us know in the comments below!
Image Credit: Fabrik Bilder via Shutterstock.com