Bulk Replace
How-to

How to Use Notepad++ to Replace Text in All Files in a Folder

Use Notepad++ Find in Files to replace text across a whole folder, with filters, subfolders and regex. Plus how to protect yourself before you click.

Updated 5 minute read The Bulk Replace team

To replace text in all files with Notepad++, open Search → Find in Files (or press Ctrl+Shift+F), enter the text to find and the replacement, set Filters to the file types you want and Directory to the folder, tick In all sub-folders if needed, and click Replace in Files. Notepad++ asks you to confirm, then edits and saves every matching file on disk.

That last part is what to plan for: the files are changed directly, including ones you never opened. Here is how to fill in each field correctly, use regex safely, and protect yourself before you click.

Step by step: Replace in Files

  1. Open the dialog. Press Ctrl+Shift+F, or use Search → Find in Files. Make sure the Find in Files tab is selected at the top.
  2. Find what. Type the exact text to search for.
  3. Replace with. Type the new text. Leave it empty to delete the matches.
  4. Filters. Enter file patterns separated by spaces, such as *.html *.css *.js. Use *.* for everything, but be careful: that includes files you may not want to touch.
  5. Directory. Click the ... button to pick the folder, or tick Follow current doc. to use the folder of the file you have open.
  6. Sub-folders and hidden folders. Tick In all sub-folders to include the whole tree. Only tick In hidden folders if you really need to search places like .git, which you normally should not edit.
  7. Match options. Set Match whole word only and Match case as needed, and choose a Search Mode: Normal, Extended or Regular expression.
  8. Check first. Click Find All. The Search results panel lists every file and line that matches, with a total count. Read it.
  9. Replace. Click Replace in Files and confirm the "Are you sure?" prompt. Notepad++ reports how many occurrences were replaced.

Excluding files and folders

The Filters box can also exclude. Prefix a pattern with ! to leave it out, for example:

*.js !*.min.js

That searches JavaScript files but skips minified copies. Newer versions also support excluding folders with a !\ prefix, such as !\node_modules; check the Searching page of the Notepad++ user manual for the exact syntax your version supports. If the Filters box contains only exclusions, add a positive pattern like *.* so there is something to search.

Search modes: Normal, Extended and Regular expression

ModeWhat it doesExample
NormalLiteral text. Every character means itself.example.com matches only that text
ExtendedLiteral text plus escapes like \n, \r and \t\r\n\r\n finds a blank line in a Windows file
Regular expressionFull regex with groups, classes and anchors(\d{2})/(\d{2})/(\d{4})

In Regular expression mode, use $1 or \1 in Replace with to insert a captured group. For example, find (\d{2})/(\d{2})/(\d{4}) and replace with $3-$2-$1 to turn 31/12/2025 into 2025-12-31. There is also a . matches newline checkbox that lets . match line breaks, which is what you need for multi-line patterns.

If your pattern is not matching what you expect, our regex cheat sheet for find and replace covers the syntax, including what needs escaping.

Useful patterns for Replace in Files

These work in Regular expression mode. Test each one with Find All before replacing.

TaskFind whatReplace with
Remove trailing spaces and tabs[ \t]+$(empty)
Change http to https for your domainhttp://(www\.)?example\.comhttps://$1example.com
Delete lines containing a word^.*DEBUG.*\R(empty)
Swap single quotes for double in class attributesclass='([^']*)'class="$1"
Update a year range2019-20\d\d2019-2026

\R is a Notepad++ (Boost) shorthand that matches any line ending, whether \r\n, \n or \r. Other tools may not support it, so use \r?\n elsewhere.

Protect yourself before you click Replace in Files

Replace in Files writes changes straight to disk for files that are not open in Notepad++. Undo (Ctrl+Z) only works inside documents that are open in the editor, so for everything else there is no simple way back. Before any large replace:

  • Back up the folder. Copy it, or commit it to version control.
  • Run Find All first and compare the count with what you expect.
  • Narrow the filters to the extensions you mean. A replace over *.* also reaches logs, data files and anything else in the tree.
  • Try it on one subfolder before the whole tree.

If a replace has already gone wrong, see how to undo a find and replace in multiple files.

Notepad++ has two other bulk options that are easy to confuse with Replace in Files:

  • Replace All in All Opened Documents (on the Replace tab) changes only the files currently open in tabs. These changes stay unsaved until you save, so undo works per file.
  • Replace All (on the Replace tab) works only on the current document.

For a folder tree you have not opened, Replace in Files is the one you want.

Common problems

"0 occurrences were replaced"

  • The Filters box does not match the files, for example *.htm when the files are .html.
  • Search Mode is set to Regular expression and your text contains characters like . ( or ?. Switch to Normal or escape them.
  • The text spans lines, and the line endings in the files are \n rather than \r\n. Use \r?\n in a regex.
  • Match whole word only or Match case is ticked when it should not be.

Accented characters look wrong afterwards

Notepad++ detects each file's encoding as it opens it, but detection can guess wrong on files without a byte order mark. Check the Encoding menu on an affected file. Our guide to find and replace not finding text also covers encoding-related misses.

When you need more control than Find in Files

Notepad++ is a solid choice for a single replacement across a folder. For bigger jobs, a dedicated batch tool adds safety features that Find in Files does not have. Bulk Replace shows a before/after diff of every match in every file and lets you untick individual files or matches before anything is written. Every run backs up the files it changes, so one click restores the whole job. You can stack many rules, or import them from a CSV, and run them in order in one pass, with filters for extension, size, modified date and hidden files. Bulk Replace also skips binary files automatically and preserves each file's encoding.

A good rule of thumb: if you would be nervous about the result, use a method that lets you see it first and take it back afterwards.

Frequently asked questions

Where is Replace in Files in Notepad++?

Open the Search menu and choose Find in Files, or press Ctrl+Shift+F. Fill in Find what, Replace with, Filters and Directory, then click Replace in Files.

Can I undo Replace in Files in Notepad++?

Files that are not open in the editor are changed and saved on disk, so there is no simple undo. Back up the folder or use version control before running it.

How do I include subfolders in Notepad++ Find in Files?

Tick In all sub-folders in the Find in Files tab. Tick In hidden folders as well only if you really want those searched.

Get three guides like this every month, plus software update notices.Subscribe →