Forum Discussion
Timothy310
Feb 22, 2025Iron Contributor
Find a text file containing a particular phrase.
In a folder on my data drive, I have hundreds of text (.txt) files I have created or otherwise accumulated over the past decade or so. A lot of times, I want to find a file containing particular phr...
Sajjad
Feb 22, 2025Brass Contributor
Hello Timothy310
You can achieve this using command-line tools.
Windows (PowerShell):
Get-ChildItem -Path "C:\Your\Folder\Path" -Recurse -File | Select-String -Pattern "Your Phrase"
- Replace "C:\Your\Folder\Path" with the actual path to your folder.
- Replace "Your Phrase" with the phrase you're searching for.
- -Recurse searches subfolders as well.
- -File limits the search to files (not directories).
- Select-String is the command for searching text within files.
In summary: The command-line approach is the most efficient and recommended for finding a phrase in a text file across many files in your folder.