The easiest way to find and replace text inside multiple text files simultaneously in Windows is to use Notepad++, which is free.
Method 1 – Notepad++ (recommended)
- Download and install Notepad++ from https://notepad-plus-plus.org/.
- Open Notepad++.
- Press Ctrl + Shift + F to open Find in Files.
- Complete the following fields:
| Field | Example |
| Find what | Old text |
| Replace with | New text |
| Filters | *.txt |
| Directory | D:\rubbish\data |
| In all sub-folders | Tick if required |
| Match case | Tick if capitalisation matters |
| Search Mode | Normal |
- Click Find All if you want to preview the matches before making changes.
- Click Replace in Files.
- Confirm the operation.
Notepad++ will automatically open, modify and save the relevant files.
Different file types
You can restrict the operation to particular types of files:
| Filter | Files affected |
| *.txt | Text files |
| *.csv | CSV data files |
| *.py | Python scripts |
| *.cpp | C++ source code |
| *.grc | GNU Radio flowgraphs |
| *.txt *.csv | Both text and CSV files |
| *.* | All file types |
Method 2 – Windows PowerShell
You can also do this without installing additional software.
For example, to replace Old text with New text inside every text file in a directory:
Get-ChildItem “D:\rubbish\data” -Filter *.txt | ForEach-Object {
$content = Get-Content $_.FullName -Raw
$content = $content.Replace(“Old text”, “New text”)
Set-Content $_.FullName -Value $content -NoNewline
}
To include all subdirectories, add -Recurse after -Filter *.txt.
Be aware that PowerShell may change the character encoding of your files, depending on the version used.
I would recommend Notepad++, particularly for modifying large numbers of radio astronomy data files or software source files.
Important: Make a backup of the directory before performing a bulk replacement, as changes across multiple files may not be easily undone.