To find all files containing specific text on Windows, the most reliable built-in options are the command line tools: findstr /s /i /m "word" *.* in Command Prompt, or Get-ChildItem -Recurse -File | Select-String 'word' -List in PowerShell. Both read the files directly and list every match. File Explorer can also search inside files with content:word, but only reliably in indexed locations. Code editors such as VS Code and Notepad++ add a clickable results list with line numbers.
Here is how to use each one, what they miss, and how to get counts as well as file names.
Option 1: File Explorer content search
- Open the folder in File Explorer.
- Click the search box at the top right and type
content:yourword. - Press Enter and wait for results.
Explorer content search relies on the Windows Search index. In indexed locations (your user folders by default) it is fast. In other folders it can be slow or miss files unless you turn on Always search file names and contents: open File Explorer Options (Folder Options), go to the Search tab, and tick it under "When searching non-indexed locations".
Even then, Explorer only reads the contents of file types that have a filter registered for indexing. Many code and config extensions are indexed as properties only. You can change this in Indexing Options → Advanced → File Types, by selecting an extension and choosing "Index Properties and File Contents". For developer folders, the command line is usually quicker.
Option 2: findstr in Command Prompt
findstr has been part of Windows for decades and needs no setup. Open Command Prompt, cd to the folder, and run:
findstr /s /i /m "oldname" *.html *.css *.js
| Switch | Meaning |
|---|---|
/s | Search the current folder and all subfolders |
/i | Ignore case |
/m | Print only the names of files that contain a match |
/n | Show line numbers (use instead of /m to see the lines) |
/c:"text" | Search for the exact phrase, including spaces |
/r | Treat the search as a (limited) regular expression |
The most common surprise: findstr "new york" *.txt finds lines containing new OR york, because spaces separate alternative search terms. Use /c:"new york" for the phrase.
Limits to know: findstr's regex support is basic (no +, no {n} counts, no groups), and it does not handle UTF-16 files or non-ASCII text in UTF-8 files reliably.
Option 3: Select-String in PowerShell
PowerShell's Select-String is the modern equivalent and supports full .NET regular expressions.
List the files that contain the text
Get-ChildItem -Recurse -File -Include *.html,*.php | Select-String -Pattern 'oldname' -List | Select-Object Path
-List stops after the first match in each file, so you get one line per file.
Show every matching line
Get-ChildItem -Recurse -File -Include *.html,*.php | Select-String -Pattern 'oldname'
Each result shows the file, line number and line text.
Count matches per file
Get-ChildItem -Recurse -File -Include *.html | Select-String -Pattern 'oldname' -AllMatches | ForEach-Object { foreach ($m in $_.Matches) { $_.Path } } | Group-Object | Sort-Object Count -Descending | Select-Object Count, Name
That gives a table of files ranked by how many times the text appears.
Useful switches
-SimpleMatch: treat the pattern as literal text, so dots and brackets do not need escaping.-CaseSensitive: Select-String ignores case by default.-NotMatch: show lines that do not match.-Context 2: show two lines before and after each match.
To export the results for a spreadsheet, end the pipeline with | Select-Object Path, LineNumber, Line | Export-Csv matches.csv -NoTypeInformation.
Option 4: a code editor
- VS Code: open the folder and press Ctrl+Shift+F. Results are grouped by file with a count for each, and clicking a result opens the line. Use files to include to limit the types.
- Notepad++: press Ctrl+Shift+F, set the Directory and Filters, tick In all sub-folders, and click Find All. The Search results panel lists each file and line with a total hit count.
Editors are pleasant for browsing results. For very large trees or scripted reports, the command line is faster.
Searching for several words or a pattern
Real searches are often more specific than a single word:
- Any of several words:
findstr /s /i /m "alpha beta" *.txtfinds files containing alpha or beta. In PowerShell, pass several patterns:Select-String -Pattern 'alpha','beta'. - Files containing both words: chain two searches in PowerShell:
Get-ChildItem -Recurse -File | Where-Object { (Select-String -Path $_.FullName -Pattern 'alpha' -Quiet) -and (Select-String -Path $_.FullName -Pattern 'beta' -Quiet) }. - Files that do NOT contain a word:
findstr /s /i /v /mdoes not do this (it lists files with any non-matching line). In PowerShell useWhere-Object { -not (Select-String -Path $_.FullName -Pattern 'word' -Quiet) }. - A pattern: e.g. every email address at an old domain:
Select-String -Pattern '[\w.+-]+@olddomain\.com'.
Which method should you use?
| Need | Best option |
|---|---|
| Documents in your user folders | File Explorer content: |
| Quick list of file names, no setup | findstr /s /i /m |
| Regex, counts, or a CSV report | Select-String |
| Clicking through matches in context | VS Code or Notepad++ |
| Finding matches you are about to replace | A replace tool's preview |
When you are searching because you plan to replace
Often the reason for finding every file that contains a word is that you are about to change it. In that case, search and replace are best done in the same place, so the list of matches you review is exactly the list that gets changed. In Bulk Replace, you choose the folder and filters, add your rule, and the preview lists every matching file with its match count and a before/after view of each change. You can stop there and change nothing, or untick files and matches you want to keep and then apply. After a run, Bulk Replace writes a timestamped report of files changed and match counts can be exported as CSV.
For the replace step itself, see how to find and replace text in multiple files.
Why a search might miss files
- Encoding. UTF-16 files store each character in two bytes, so simple byte-based tools miss them. Select-String detects UTF-16 files that have a byte order mark.
- Hidden files.
Get-ChildItemskips hidden files and folders unless you add-Force. - The text is not what you think. A non-breaking space, a curly apostrophe or an HTML entity like
&looks the same on screen but is different in the file. - Binary or compressed formats. Word .docx, Excel .xlsx and PDF files are compressed, so text search tools cannot see inside them. Use Explorer's indexed search or the program that created them.
Our troubleshooting guide, find and replace not finding text, goes through each of these in detail.
Frequently asked questions
Why does File Explorer not find text inside my files?
Content search relies on the Windows index and only covers indexed locations and file types. Check Indexing Options, or use findstr or Select-String, which read the files directly.
What command lists files containing a word?
In Command Prompt, findstr /s /i /m "word" *.txt lists matching .txt files in the folder and subfolders. In PowerShell, use Get-ChildItem -Recurse -File | Select-String 'word' -List.
Can I search for a regex pattern inside files?
Yes. Select-String uses regular expressions by default, and findstr supports a limited regex syntax with /r.
