# ------------------ duplicate_cries.ps1 ------------------
# This script duplicates every file named "*_cry.ogg" in
# the current folder (and all subfolders), creating an
# "*_ambient.ogg" copy of each.

Write-Host "Starting duplication of *_cry.ogg files..."

# $PSScriptRoot is the folder where this .ps1 script resides
Set-Location -Path $PSScriptRoot

# Recursively find all *_cry.ogg files
Get-ChildItem -Path $PSScriptRoot -Filter "*_cry.ogg" -File -Recurse | ForEach-Object {
    $oldFile  = $_.FullName
    $baseName = $_.BaseName -replace "_cry$", "_ambient"  # e.g. "abra_cry" → "abra_ambient"
    $newFile  = Join-Path $_.DirectoryName "$baseName$($_.Extension)"  # keep .ogg extension

    Write-Host "Copying $($oldFile) to $($newFile)"
    Copy-Item -Path $oldFile -Destination $newFile -Force
}

Write-Host "All done!"
Write-Host "Press Enter to close."
Read-Host
# ------------------ End of script ------------------
