To limit a find and replace to specific file types, set an extension filter before you run it. In PowerShell, use Get-ChildItem -Recurse -File -Include *.html,*.php. In Notepad++ Find in Files, type *.html *.php in the Filters box. In VS Code, type *.{html,php} in files to include. Then exclude the folders you never want touched, such as node_modules, .git, vendor and build output, and make sure images and other binary files are skipped. A good filter is the single most effective protection against a bulk replace going wrong.
Below are the exact filter syntaxes for each tool, a table of sensible filter sets by job, and the folders and files that should almost always be excluded.
Why filtering matters
A replace without a filter reaches every file in the folder tree. That includes:
- Binary files such as images, PDFs, archives and executables, which a text replace can corrupt.
- Third-party code in
node_modulesorvendor, which will be overwritten at the next update anyway. - Generated files such as minified scripts and build output, which should be regenerated from source rather than edited.
- Version control internals in
.git, where any change can damage the repository. - Logs and lock files that record history or exact versions.
Filtering also makes the preview readable. Two hundred relevant matches are easy to review. Twenty thousand matches, most of them in vendor code, are not.
PowerShell
For a single extension, -Filter is fastest:
Get-ChildItem -Path C:\site -Recurse -File -Filter *.html
-Filter accepts only one pattern. For several extensions, use -Include:
Get-ChildItem -Path C:\site -Recurse -File -Include *.html,*.css,*.php
In Windows PowerShell 5.1, -Include only works as expected together with -Recurse or a path that ends in a wildcard such as C:\site\*. Without either, it can return nothing.
To exclude folders, filter on the full path:
Get-ChildItem -Path C:\site -Recurse -File -Include *.js | Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|vendor|dist)\\' }
The pattern looks for the folder name with a backslash on each side, so vendors or distance.js are not excluded by accident. -Exclude also exists, but it applies to file and folder names, not to everything inside an excluded folder, so the Where-Object form is more reliable. Pipe the result into your replace loop as shown in the PowerShell replace guide.
Notepad++
In Search → Find in Files (Ctrl+Shift+F):
- Filters: patterns separated by spaces, such as
*.html *.css *.js. - Exclusions: recent versions accept patterns starting with
!, such as*.js !*.min.js. Folder exclusions are supported too; check the Find in Files section of the Notepad++ user manual for the exact form your version uses. - In all sub-folders and In hidden folders checkboxes control depth and whether hidden folders are searched.
The Notepad++ Replace in Files guide walks through the full dialog.
VS Code
In the Search view (Ctrl+Shift+F, or Ctrl+Shift+H with replace), click the three dots to show the include and exclude boxes:
- files to include: glob patterns separated by commas, such as
*.html, *.css, or*.{html,css}, or a folder such assrc/**. - files to exclude: such as
**/dist/**, *.min.js. - The gear icon in the exclude box, Use Exclude Settings and Ignore Files, applies your
files.excludeandsearch.excludesettings and your.gitignore. It is on by default, which already skipsnode_modules.
In VS Code globs, * matches within one folder level and ** matches any number of levels.
Filter sets by job
| Job | Include | Exclude |
|---|---|---|
| Static website | *.html *.htm *.css *.js *.php | *.min.js, *.min.css, image and font folders |
| JavaScript project | *.js *.ts *.jsx *.tsx *.json | node_modules, dist, build, package-lock.json |
| .NET project | *.cs *.csproj *.config *.json *.cshtml | bin, obj, packages |
| Python project | *.py *.toml *.cfg *.ini *.txt | venv, .venv, __pycache__ |
| Server config | *.conf *.ini *.config *.xml *.yml *.env | *.log, backup folders |
| Documentation | *.md *.txt *.html | Changelog files, generated API docs |
Always exclude .git and any other version control folder, whatever the job.
Beyond extensions: size, date and hidden files
Extension is the main filter, but a few others are useful:
- Modified date. Change only files edited after a certain date, for example pages added since the last migration. In PowerShell:
Where-Object { $_.LastWriteTime -gt '2025-01-01' }. - File size. Skip very large files such as data dumps that happen to share an extension:
Where-Object { $_.Length -lt 5MB }. - Hidden files.
Get-ChildItemskips hidden files unless you add-Force. Decide deliberately whether files like.htaccessor.envshould be included.
Files with no extension, or an unusual one
Some important text files do not fit an extension filter. Dockerfile, Makefile, LICENSE and README often have no extension at all, and dot-files such as .htaccess, .gitignore and .editorconfig are all extension and no name. Many projects also use their own extensions for templates or data, such as .tpl, .tmpl or .inc.
Add them to the filter by full name: in PowerShell, -Include *.php,*.inc,.htaccess; in Notepad++, *.php *.inc .htaccess; in VS Code, *.{php,inc}, **/.htaccess. Before a big job, it is worth listing every extension in the folder so nothing is missed: Get-ChildItem -Recurse -File | Group-Object Extension | Sort-Object Count -Descending shows each extension with a file count.
A batch tool with filters in one place
Bulk Replace puts these filters on one screen: include sub-folders, extension filters, file size, modified date and hidden files. It also detects binary files and skips them automatically, even when no extension filter is set, so an image with a matching byte sequence is never touched. The preview lists every file that will change, which is the final check that the filter did what you meant. If a file type slipped through, untick it, or undo the whole run in one click, since Bulk Replace backs up every file first.
Check before you replace
- Run the search with your filters and look at the list of files, not just the matches.
- Sort or scan by folder. Any path containing
node_modules,vendor,distor.gitmeans the exclusions need work. - Check the extensions in the list match the ones you meant to include.
- Only then run the replace.
Frequently asked questions
How do I filter by more than one extension in PowerShell?
Use -Include with -Recurse, for example Get-ChildItem -Recurse -File -Include *.html,*.php. The -Filter parameter accepts only one pattern.
How do I filter file types in Notepad++ Find in Files?
Type the patterns in the Filters box separated by spaces, such as *.html *.css. Recent versions also accept exclusions such as !*.min.js.
How do I filter file types in VS Code?
In the Search view, type a glob such as *.{html,css} in files to include, and folder or file patterns in files to exclude.
