extract_successful_ids.ps1 988 B

123456789101112131415161718192021
  1. if (Test-Path -Path $args[0] -PathType Leaf) {
  2. $file=$args[0]
  3. }
  4. else {
  5. Write-Host "CANNOT FIND LOG FILE"
  6. Exit 1
  7. }
  8. if ($args[1] -ne $null) {
  9. $output=$args[1]
  10. Write-Host "Outputting IDs to $output"
  11. }
  12. else {
  13. $output="./successful.txt"
  14. }
  15. Select-String -Path $file -Pattern "Downloaded submission" | ForEach-Object { -split $_.Line | Select-Object -Last 3 | Select-Object -SkipLast 2 } >> $output
  16. Select-String -Path $file -Pattern "Resource hash" | ForEach-Object { -split $_.Line | Select-Object -Last 3 | Select-Object -SkipLast 2 } >> $output
  17. Select-String -Path $file -Pattern "Download filter" | ForEach-Object { -split $_.Line | Select-Object -Last 4 | Select-Object -SkipLast 3 } >> $output
  18. Select-String -Path $file -Pattern "already exists, continuing" | ForEach-Object { -split $_.Line | Select-Object -Last 4 | Select-Object -SkipLast 3 } >> $output
  19. Select-String -Path $file -Pattern "Hard link made" | ForEach-Object { -split $_.Line | Select-Object -Last 1 } >> $output