DOCX files are binary ZIP archives and rg can’t search them directly. The fix is to pipe each file through pandoc, which converts DOCX to plain text (or Markdown) on the fly before rg searches it.

Prerequisites

Install both tools if you don’t have them:

winget install BurntSushi.ripgrep.MSVC
winget install JohnMacFarlane.Pandoc

Search all DOCX files recursively

Get-ChildItem *.docx -Recurse | % {
    echo "---"
    echo $_.Name
    pandoc $_.FullName -t markdown | rg -i 'my search string'
}
Argument Meaning
*.docx Glob pattern, match only .docx files
-Recurse Walk subdirectories recursively
% Alias for ForEach-Object, runs the block for each file
$_.FullName Full absolute path of the current file (required by pandoc)
-t markdown Tell pandoc to output Markdown; preserves heading structure so you can see where in the document a match falls
-i Case-insensitive search in ripgrep
'my search string' The search query (use single quotes in PowerShell to prevent string interpolation)

Show context around matches

Use -C to print lines before and after each match:

Get-ChildItem *.docx -Recurse | % {
    echo "---"
    echo $_.Name
    pandoc $_.FullName -t markdown | rg -i -C 2 'my search string'
}

Search only the current directory (non-recursive)

Drop the -Recurse flag:

Get-ChildItem *.docx | % {
    echo "---"; echo $_.Name
    pandoc $_.FullName -t markdown | rg -i 'my search string'
}

Why -t markdown and not -t plain?

Either works for searching. -t markdown preserves heading structure, which makes it easier to see where in a document a match falls. Use -t plain if you want cleaner output with no Markdown syntax in the results:

pandoc $_.FullName -t plain | rg -i 'my search string'

Bonus: syntax-highlighted results with bat

bat is a cat replacement with syntax highlighting. Pipe the rg results into bat -l md to get highlighted output:

Get-ChildItem *.docx -Recurse | % { echo $_.Name; pandoc $_.FullName -t markdown | rg -i 'fox' | bat -l md }

-l md tells bat to treat the input as Markdown (since it’s coming from stdin with no filename to infer the language from).

Install bat with:

winget install sharkdp.bat

Performance note

pandoc converts one file at a time and can be slow for large or many documents. For hundreds of large DOCX files, filter the file list first.