Untitled

 avatar
unknown
plain_text
13 days ago
2.7 kB
13
Indexable
# 1. Setup the output folder
$finalFolder = Join-Path $PWD "Extracted_Wems"
if (!(Test-Path $finalFolder)) { New-Item -ItemType Directory -Path $finalFolder }

# 2. Find all .bnk files
$bnkFiles = Get-ChildItem -Filter *.bnk

if ($bnkFiles.Count -eq 0) {
        Write-Host "ERROR: No .bnk files found in $PWD" -ForegroundColor Red
            Write-Host "Make sure you opened the terminal in the correct folder." -ForegroundColor Yellow
                return
}

# 3. Process each .bnk file
foreach ($bnkFile in $bnkFiles) {
        $baseName = $bnkFile.BaseName
            Write-Host "Extracting: $($bnkFile.Name)..." -ForegroundColor Cyan

                # Run the extractor directly
                    ./bnkextr.exe "$($bnkFile.Name)"

                        # Give the hard drive a split second to catch up
                            Start-Sleep -Milliseconds 500

                                # 4. Find the numbered files (001.wem, 002.wem, etc.)
                                    $extractedFiles = Get-ChildItem | Where-Object { $_.BaseName -match '^\d+$' -and ($_.Extension -eq '.wem' -or $_.Extension -eq '.wav') }

                                        if ($extractedFiles.Count -gt 0) {
                                                    $count = 1
                                                            foreach ($file in $extractedFiles) {
                                                                            $newName = "{0}_{1:D3}{2}" -f $baseName, $count, $file.Extension
                                                                                        
                                                                                                    # Move and rename into the final folder
                                                                                                                Move-Item -Path $file.FullName -Destination "$finalFolder\$newName" -Force
                                                                                                                            $count++
                                                            }
                                                                    Write-Host "Success: Moved $($count-1) files from $baseName" -ForegroundColor Green
                                        } else {
                                                    Write-Host "Warning: No numbered files found for $baseName" -ForegroundColor Yellow
                                        }
}

Write-Host "`nDone! Check the 'Extracted_Wems' folder." -ForegroundColor White
                                        }
                                                            }
                                        }
}
}
Editor is loading...
Leave a Comment