Search code examples
powershellsearch.doc

Searching for strings within file names using PowerShell


I've just started a new job, and we write reports for clients that are helpful for me to read to learn the ropes. I was trying to use PowerShell to pipe the titles into a text file, but unfortunately the company only standardised titles recently. This means that reports can be named anything, but having a look through the .docs, a lot of them have the word "report" in the title. Is there anyway that I could adapt my current commands to search more liberally for the word "report"?

Get-ChildItem -recurse -include *.doc | Out-File P:\report.txt

Solution

  • Most efficient version should be

    Get-ChildItem -Path "your path here" -recurse -Filter *report*.doc | Out-File P:\report.txt
    

    or if you only want the path in your file:

    Get-ChildItem -Path "your path here" -recurse -Filter *report*.doc |  Select -ExpandProperty Fullname | Out-File P:\report.txt