Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Last active May 14, 2023 16:41
Show Gist options
  • Select an option

  • Save SteveGilham/c916d7b360fae82bce4f36eaf22d5361 to your computer and use it in GitHub Desktop.

Select an option

Save SteveGilham/c916d7b360fae82bce4f36eaf22d5361 to your computer and use it in GitHub Desktop.

Revisions

  1. SteveGilham revised this gist May 14, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions scan.ps1
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    [System.IO.Directory]::GetFiles((Get-Location), "?????-*.png") |
    Group-Object -Property {[System.DateOnly]::FromDateTime([System.IO.File]::GetCreationTime($_))} |
    Sort-Object -Property {[System.DateOnly]::Parse($_.Name)} | % {
    Group-Object -Property {[System.DateTime]::Parse([System.IO.File]::GetCreationTime($_).ToShortDateString())} |
    Sort-Object -Property {[System.DateTime]::Parse($_.Name)} | % {
    $names = $_.Group | Sort-Object -Property {[System.IO.File]::GetCreationTime($_)}
    [PSCustomObject]@{
    Key = $_.Name
    Value = $names
    }
    } | % {
    Write-Output $_.Key
    Write-Output ($_.Key.Split())[0]
    $_.Value | % {
    " `"$([System.IO.Path]::GetFileName($_).Substring(0,5))`"" | Write-Output
    $bytes = [System.IO.File]::ReadAllBytes($_)
    @@ -28,4 +28,4 @@
    $index = ($index + 12 + $length)
    }
    }
    }
    }
  2. SteveGilham created this gist May 14, 2023.
    31 changes: 31 additions & 0 deletions scan.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    [System.IO.Directory]::GetFiles((Get-Location), "?????-*.png") |
    Group-Object -Property {[System.DateOnly]::FromDateTime([System.IO.File]::GetCreationTime($_))} |
    Sort-Object -Property {[System.DateOnly]::Parse($_.Name)} | % {
    $names = $_.Group | Sort-Object -Property {[System.IO.File]::GetCreationTime($_)}
    [PSCustomObject]@{
    Key = $_.Name
    Value = $names
    }
    } | % {
    Write-Output $_.Key
    $_.Value | % {
    " `"$([System.IO.Path]::GetFileName($_).Substring(0,5))`"" | Write-Output
    $bytes = [System.IO.File]::ReadAllBytes($_)
    $index = 8
    $found = $false
    while (($index -lt $bytes.Length) -and (-not $found)) {
    # Write-Output "index = $index"
    $field = ($bytes[$index+3], $bytes[$index+2], $bytes[$index+1], $bytes[$index])
    $length = [System.BitConverter]::ToInt32($field, 0)
    # Write-Output "length = $length"
    $chunk = [System.Text.Encoding]::ASCII.GetString($bytes, $index+4, 4)
    # Write-Output "chunk = $chunk"
    if ($chunk.Equals("tEXt")) {
    $found = $true
    $body = [System.Text.Encoding]::ASCII.GetString($bytes, $index+19, $length - 11)
    Write-Output $body
    }
    $index = ($index + 12 + $length)
    }
    }
    }