public/Compress-FootballCompetitionPrediction.ps1
function Compress-FootballCompetitionPrediction { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$PredictionList, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path ) process{ $ErrorActionPreference = 'Stop' try { $PredictionList | ForEach-Object { # fra-ligue1\2025-02-08 $SplitString = "$($_.Path)".Split("\$($_.competition)-240")[0] $FileName = $SplitString.Replace('\','-') $PathToZip = "$Path\sportsmonk-predictions\$SplitString" $Target = "$Path\fixture-artifact\ko-fi\$($_.competition)\$FileName-$($_.FixturesToPlay)" $TargetExists = Test-Path -Path "$Path\fixture-artifact\ko-fi\$($_.competition)" if (!$TargetExists) { New-Item -Path "$Path\fixture-artifact\ko-fi\$($_.competition)" -ItemType Directory -Verbose | Out-Null } # if $Compress = @{ Path = $PathToZip CompressionLevel = "Fastest" DestinationPath = "$Target.zip" } $Compress | Format-Table Compress-Archive @compress -Force -Verbose } } catch { $_.Exception.Message S } } # process } # function |