#requires -PSEdition Core " PLATO Target File Size Estimator" $line = $null # $PSVersionTable.PSVersion $PatchFolder = $PSScriptRoot + "\CybdevPatches" if ($args[0]) { $PatchFolder = $args[0] } Get-ChildItem $PatchFolder -Filter "pf.*.*.txt" | Foreach-Object { $content = Get-Content $_.FullName $blkcount = 1 $typecounts = [ordered]@{"(*directory)" = 1} foreach($line in $content) { if($line -match "CTL[+|-].*SEQ"){ $filename = $line.Substring(8,10) $blocknum = $line.Substring($line.IndexOf("SEQ") + 3) $blocknum = [convert]::ToInt32($blocknum) $type = $line.Substring($line.IndexOf("TYP") + 3, 10).Trim() switch ($type){ "charset" { # At least one block } "common" { # Wait for a length } default { $blkcount += 1 $typecounts.$type += 1 } } } $lcommon = $line.Substring(0,11) if ($type -eq "common" -and $lcommon -eq "TXTlcommon=") { $nwords = [convert]::ToInt32($line.Substring(11)) $nblocks = [convert]::ToInt32($nwords / 320) if ([convert]::ToInt32($nwords % 320 -gt 0)) { $nblocks += 1 } $blkcount += $nblocks $typecounts.$type += $nblocks } $txtchar = $line.Padright(14).Substring(0,14) if ($type -eq "charset" -and $txtchar -eq "TXTchar 127") { $blkcount += 1 $typecounts.$type += 1 } if ($type -eq "charset" -and $txtchar -eq "TXTchar 128") { $blkcount += 1 $typecounts.$type += 1 } } $nparts = [Math]::Ceiling($blkcount / 7) $_.BaseName.PadRight(24) + ` "Contains " + $filename.PadRight(" ",10) + ` " BlkCount=" + $blkcount.ToString("0000") + ` " MinParts=" + $nparts.ToString("000") " " + $_.FullName foreach($type in $typecounts.Keys){ " " + $type.PadRight(12) + $typecounts.$type + " Blocks" } }