► Show Spoiler
$divinePath = "path to divine.exe"
$pakPath = "path to *.pak file"
$outDir = "path to output"
$tempList = "pak_contents.txt"
# 1. Generate and Clean List
Write-Host "Generating list..." -ForegroundColor Cyan
& $divinePath -g bg3 -a list-package -s $pakPath | Out-File -FilePath $tempList -Encoding UTF8
$filesToExtract = Get-Content $tempList | ForEach-Object {
$trimmed = $_.Trim()
if ($trimmed -match '[\\/]') {
$path = ($trimmed -split "\s+(?=\d)", 2)[0].Trim()
if ($path -notmatch '\.md$') { $path }
}
}
$totalFiles = $filesToExtract.Count
Write-Host "Filtered list contains $totalFiles files. Starting 4 worker threads..." -ForegroundColor Green
# 2. Split into 4 Batches
$batchSize = [Math]::Ceiling($totalFiles / 4)
$batches = 0..3 | ForEach-Object {
$start = $_ * $batchSize
$end = [Math]::Min($start + $batchSize - 1, $totalFiles - 1)
if ($start -lt $totalFiles) {
,($filesToExtract[$start..$end])
}
}
# 3. Launch Jobs
$jobs = foreach ($batch in $batches) {
Start-Job -ArgumentList $divinePath, $pakPath, $outDir, $batch -ScriptBlock {
param($dPath, $pPath, $rootOut, $fileList)
foreach ($cleanPath in $fileList) {
$destFile = Join-Path $rootOut $cleanPath
$destFolder = Split-Path $destFile -Parent
if (-not (Test-Path $destFolder)) { New-Item -ItemType Directory -Path $destFolder -Force | Out-Null }
# Execute extraction
& $dPath -g bg3 -a extract-single-file -s $pPath -f $cleanPath -d $destFile
}
}
}
# 4. Wait for completion
Write-Host "Extracting... (this will be much faster)" -ForegroundColor Yellow
$jobs | Wait-Job | Out-Null
# Cleanup
$jobs | Remove-Job
Write-Host "Done! All files (except .md) extracted." -ForegroundColor Green
$pakPath = "path to *.pak file"
$outDir = "path to output"
$tempList = "pak_contents.txt"
# 1. Generate and Clean List
Write-Host "Generating list..." -ForegroundColor Cyan
& $divinePath -g bg3 -a list-package -s $pakPath | Out-File -FilePath $tempList -Encoding UTF8
$filesToExtract = Get-Content $tempList | ForEach-Object {
$trimmed = $_.Trim()
if ($trimmed -match '[\\/]') {
$path = ($trimmed -split "\s+(?=\d)", 2)[0].Trim()
if ($path -notmatch '\.md$') { $path }
}
}
$totalFiles = $filesToExtract.Count
Write-Host "Filtered list contains $totalFiles files. Starting 4 worker threads..." -ForegroundColor Green
# 2. Split into 4 Batches
$batchSize = [Math]::Ceiling($totalFiles / 4)
$batches = 0..3 | ForEach-Object {
$start = $_ * $batchSize
$end = [Math]::Min($start + $batchSize - 1, $totalFiles - 1)
if ($start -lt $totalFiles) {
,($filesToExtract[$start..$end])
}
}
# 3. Launch Jobs
$jobs = foreach ($batch in $batches) {
Start-Job -ArgumentList $divinePath, $pakPath, $outDir, $batch -ScriptBlock {
param($dPath, $pPath, $rootOut, $fileList)
foreach ($cleanPath in $fileList) {
$destFile = Join-Path $rootOut $cleanPath
$destFolder = Split-Path $destFile -Parent
if (-not (Test-Path $destFolder)) { New-Item -ItemType Directory -Path $destFolder -Force | Out-Null }
# Execute extraction
& $dPath -g bg3 -a extract-single-file -s $pPath -f $cleanPath -d $destFile
}
}
}
# 4. Wait for completion
Write-Host "Extracting... (this will be much faster)" -ForegroundColor Yellow
$jobs | Wait-Job | Out-Null
# Cleanup
$jobs | Remove-Job
Write-Host "Done! All files (except .md) extracted." -ForegroundColor Green