Skip to end of banner
Go to start of banner

Find & Search Inside Files

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Microsoft File Explorer search functions are limited to a few file types. What other options are available?

MS File Explorer – Expanding it’s Limited Default Capabilities

By default 10 File Explorer will only search for text inside a limited set of file extensions (a.k.a. file types).
The Indexing Options feature in Windows Control Panel can be set to add search support of additional file extensions.

The default supported file types include TXT files, DOCX files, LOG files, XLSX files.

DOS findstr Command

In a Windows Command prompt, the findstr command searches the current directory (in this case C:\) and all subdirectories for the pattern “COMMIT” in any file with a .cs extension and outputs only the filename.

C:\>findstr /s /m "COMMIT" *.cs

For more, see: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr

PowerShell

Search Current Directory

Searchs the current path for .bat files contain the string "Monthly".

Select-String -Path "*.bat"  -SimpleMatch -Pattern "Monthly"
Select-String -Path "*.bat" "Monthly"
  • -SimpleMatch uses a simple match rather than a regular expression match.
    In a simple match, Select-String searches the input for the text in the Pattern parameter. It doesn't interpret the value of the Pattern parameter as a regular expression statement.

Recursive Search

The PowerShell command below searches the current directory (in this case C:\) and all subdirectories for .cs files containing text with the pattern "COMMIT" and lists the filenames.

PS C:\>Get-ChildItem -Path "*.cs" -Recurse | Select-String "COMMIT" -List | Select Path

For more, see: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-5.1

NotePad++

Notepad++ is a widely used and well recommended, open source text editor. Notepad++ can be installed as a stand-alone .exe file. Notepad++ (notepad-plus-plus.org)

Notepad++ Find in Files

  • Search > Find in Files… (Ctrl + Shift + F)

  • No labels