TECH / Software & Services 3 min read

Recursive Search and Replace Text Across Files: Best Free Tools

Antonio NEMCD Author
Published May 3, 2010 · 3 min

Whenever you need to update the same string, URL, or code snippet across thousands of files buried in nested subfolders, editing them by hand is out of the question. Years ago a tiny Windows freeware utility called tReplace Tool saved me hours – today that old app is long discontinued, while modern free tools handle bulk replacements faster and much more safely.

Recursive search and replace text across files and subfolders

Here are four reliable free ways to run recursive find-and-replace on Windows, Linux, and macOS without wrecking your folder tree.

Back up your folder (or commit in Git) first: bulk replace writes directly to disk across hundreds of files – one stray regex character or missing space can’t easily be undone without a clean backup.

1. Notepad++ (Easiest GUI Option on Windows)

If you’re on Windows and prefer a straightforward desktop window, free Notepad++ chews through thousands of text files in seconds:

  1. Open Find in Files: press Ctrl + Shift + F to jump straight to the Find in Files tab.
  2. Configure scope: enter your Find what and Replace with strings, choose the root directory, set file filters (such as *.php *.html *.txt), and make sure In all sub-folders is checked.
  3. Preview before replacing: click Find All first to review every match in the results panel, then click Replace in Files once everything looks right.

2. Visual Studio Code (Windows, macOS, Linux)

Open the folder in free VS Code and press Ctrl + Shift + H (Cmd + Shift + H on macOS). Type your search and replacement text, expand the three-dot icon (⋯) to set include masks (*.md, *.json) or exclude folders (node_modules, .git), and inspect the inline diff preview for every single match before confirming.

3. grepWin and dnGrep (Modern Successors to tReplace Tool)

If you want a dedicated right-click Explorer utility (“Search and Replace in this folder”) just like the old tReplace Tool, grab open-source grepWin or dnGrep for Windows. Both handle UTF-8 cleanly, support regex and file-size filters, and can automatically create backup copies before modifying files.

Archival screenshot of the classic tReplace Tool utility

For nostalgia – the minimal interface of the classic tReplace Tool that inspired this post back in 2010.

4. Fast Command-Line One-Liners (Linux, macOS, PowerShell)

On a headless Linux server, pairing grep with sed handles recursive replacement cleanly (shown here for .html files):

grep -rl --include="*.html" "old_text" . | xargs -d '\n' sed -i 's/old_text/new_text/g'

On macOS (BSD sed), pass an empty backup suffix (sed -i ''), and if your text contains forward slashes (like URLs), switch the delimiter to a pipe: s|old_url|new_url|g.

On Windows PowerShell with zero extra installs, this pipeline updates matching UTF-8 files recursively:

Get-ChildItem -Recurse -Include *.txt,*.html | ForEach-Object { (Get-Content $_.FullName -Raw) -replace 'old_text','new_text' | Set-Content $_.FullName -NoNewline }

For everyday desktop work, Notepad++ and VS Code remain hard to beat – previewing matches before touching disk saves you from almost every accidental overwrite.

Related posts:

Leave a Comment