class Mod { $FullPath $ModId Mod($file) { $this.FullPath = $file.FullName; $this.ModId = $file.Directory.BaseName; } } $mods = New-Object System.Collections.ArrayList Get-ChildItem -Path $args[1] -Filter *.pak -Recurse -File | ForEach-Object { $mods.Add([Mod]::new($_)); } foreach ($mod in $mods) { Write-Host Unpacking mod $mod.ModId $path = Join-Path $args[2] $mod.ModId &$args[0] $mod.FullPath $path Write-Host }