Created
September 17, 2020 22:05
-
-
Save JonLevin25/513fd676f6e61b25b50e23285795afd1 to your computer and use it in GitHub Desktop.
Unity - Transcode .wavs to .mp3s with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while ( $deleteInp -notmatch "[yYnN]" ) { | |
$deleteInp = Read-Host -Prompt "Delete files when done? [y/n]" | |
} | |
$delete = $deleteInp -match "[yY]" | |
$deleteInp = "" # reset this since its global | |
echo "------ Transcoding MP3s -------" | |
$oldFileEnding='.wav' | |
$newFileEnding='.mp3' | |
Get-ChildItem -File -Recurse | Where-Object { $_.FullName.EndsWith($oldFileEnding) } | ForEach-Object { | |
$old=$_.FullName | |
$new = $old.Substring(0, $old.Length - $oldFileEnding.Length) + $newFileEnding | |
ffmpeg -i $old $new | |
if ($delete) { | |
echo "Deleting WAV $old" | |
Remove-Item $old | |
} | |
} | |
echo "------ Renaming metas -------" | |
$oldFileEnding='.wav.meta' | |
$newFileEnding='.mp3.meta' | |
Get-ChildItem -File -Recurse | Where-Object { $_.FullName.EndsWith($oldFileEnding) } | ForEach-Object { | |
$old=$_.FullName | |
$new = $old.Substring(0, $old.Length - $oldFileEnding.Length) + $newFileEnding | |
Copy-Item $old $new | |
if ($delete) { | |
echo "Deleting meta $old" | |
Remove-Item $old | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick script to transcode all .wavs to .mp3s recursively.
.meta
files to mp3 so project keeps all referencesCould reuse some stuff with a function but it works and isnt important enough to research more Powershell syntax