Quantcast
Channel: Greg – code.commongroove.com
Viewing all articles
Browse latest Browse all 30

PowerShell: Parse all Text Files in a Directory for a String Pattern

$
0
0

Here’s a snippet of PowerShell that goes through all files in a directory looking for a string. Those files that match the string pattern are then moved to another directory.

Set-Location C:\somewhere
Get-ChildItem -Recurse | Select-String -pattern "Delivery Status Notification" | Group Path | Select -ExpandProperty Name | Move-Item -Destination C:\temp\emails_moved\

Hope this helps!


Viewing all articles
Browse latest Browse all 30

Trending Articles