Created
August 23, 2021 15:36
-
-
Save ivanbuzyka/8ac2df1406717360c330fb9cde77ec31 to your computer and use it in GitHub Desktop.
Powershell script for looking through CSV using regular expression and outputting matching string. Can be used in Content Hub target job export to analyze imageMagick failures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$csvFile = Get-Item "C:\path-to-csv-file.csv" | |
$stateDescriptions = Import-Csv $csvFile -Delimiter ';' | Select-Object Target.StateDescription | |
$result1 = @() | |
foreach($desc in $stateDescriptions) | |
{ | |
# searching for filename with extension here (example pattern match /123testfile.tif:) | |
$desc -match "\/(?<filename>[^\/]*\.\w+):" #"\/\d{6}_.+\.[a-z0-9]+:" | |
if($Matches.Count -gt 0) | |
{ | |
Write-Host $Matches.filename | |
$result1 += [PSCustomObject]@{ | |
Name = $Matches.filename | |
} | |
} | |
} | |
$result1 | Select-Object Name -Unique | Export-Csv -NoTypeInformation -Path .\FileNames.csv -Delimiter ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment