public/New-FootballCompetitonWorkingSet.ps1

function New-FootballCompetitonWorkingSet {

    [CmdletBinding()]
    param(

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Competition,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Path

    )
    process{

        $ErrorActionPreference = 'Stop'

        try {

            #$Path = 'C:\Users\colin\Desktop\sportsmonk'
            #$Competition = 'eur-el'
            #$Date = '2025-02-20'

            $PathToUse = "$Path\fixture-artifact\prediction-preview"
            $FoldersToCreate = Get-ChildItem -Path "$PathToUse\$Competition"

            $Hash1 =@{
                Competition = $Competition
                FoldersToCreateCount = $($FoldersToCreate.Count)
            }

            $Hash1 | Format-Table

            foreach ($FolderToCreate in $FoldersToCreate) {

                try {

                    $CompetitionFolder = $($FolderToCreate.FullName).Split("$PathToUse\")[-1]
                    $Targetfolder = "$Path\fixture-artifact\working-set\$CompetitionFolder"
                    $TargetfolderExists = Test-Path $Targetfolder

                    if (!$TargetfolderExists) {
                        
                        New-Item -Path "$Path\fixture-artifact\working-set\$CompetitionFolder" -Type Directory | Out-Null

                    }
                    else {
                        
                        Write-Warning -Message "Folder exists: $Targetfolder."

                    } # if

                }
                catch {

                    $_.Exception.Message

                } # try catch

            } # foreach
         
        }
        catch {

            $_.Exception.Message

        } # try catch

    } # process

} # function