Forum Discussion
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 phrases or other content (e.g. all files that contain the word "recursive").
I've tried temporarily copying the folder to the C:\ drive, which is indexed by Windows (including content), but searches always come up empty.
I've tried software like Everything, Wizfile etc. No luck.
An Internet search brings up pages and pages about Windows indexing service, but nothing relevant to my needs.
Any suggestions on accomplishing this are welcome.
Thanks.
3 Replies
- afrul2020Copper Contributor
I tested it on a text file which worked fine. However how can I search from binary files such as word documents etc? Thanks
- SajjadBrass 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.