使用PowerShell在文件名中搜索字符串

时间:2016-10-06 08:53:35

标签: powershell search .doc

我刚刚开始一份新工作,我们为客户撰写有助于我阅读以学习绳索的报告。我试图使用PowerShell将标题传输到文本文件中,但遗憾的是该公司最近才对标题进行标准化。这意味着报告可以被命名为任何东西,但是看看.docs,其中很多都有"报告"在标题中。无论如何,我可以调整我当前的命令来更自由地搜索单词" report"?

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

2 个答案:

答案 0 :(得分:0)

试试这个:

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

答案 1 :(得分:0)

最有效的版本应该是

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

或者如果您只想要文件中的路径:

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