1

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
4
  • Your search the word "report" in the file name or in the content of word document? Commented Oct 6, 2016 at 8:56
  • Thanks, I'm not sure what you mean, and its not helping me with PowerShell, but thanks anyway. Commented Oct 6, 2016 at 9:01
  • @Josh, that was a question, attempting to clarify what you meant. Commented Oct 6, 2016 at 9:05
  • Ah ok, sorry. :) I'm looking to search the filename, and only the filename. Most of these report are written in word, and I understand that reading the content of Word files in PowerShell is pretty cumbersome, so the filenames should give me enough results to lookover. Commented Oct 6, 2016 at 9:10

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

Get-ChildItem -Path "your path here" -recurse -include *.doc | select-String "report" | out-file P:\report.txt

5 Comments

:( The computer didn't like that and started beeping. lol - everyone's looking at me now!
It kind of sounded like an alarm, my role isn't programming, so I'm wondering if it thought it was being hacked? Have you heard of that before?
No mate, I have no idea why your PC is acting like that. So, did you use the -Path with P:\01_Contracts (2008-2013)??? make sure you place them inside the quotes, like this: Get-ChildItem -path "P:\01_Contracts (2008-2013)"
I didn't set the path, looking at it. Thanks. I'm running it now, but it might take a while for it to filter through everything. I'll let you know how I get on. :)
For some reason it returned a bunch of gibberish, seemed to be working until I opened the text file. Thanks for the help though. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.