Created
July 13, 2023 10:20
-
-
Save ktwrd/66c6e5ca04e2a53a3f4612fda727fab9 to your computer and use it in GitHub Desktop.
Convert FLAC to MP3 Recursively
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
param( | |
# Directory to start the scan at | |
[string] | |
$Directory, | |
# When enabled, it will delete the flac file after converted to mp3 | |
[bool] | |
$DeleteOldFile=$False | |
) | |
# Convert specified file into a mp3 (will only work for .flac files) | |
function ConvertFile($InputLocation) | |
{ | |
$OutputLocation="$InputLocation".Replace(".flac", ".mp3") | |
ffmpeg -i $InputLocation -ab 320k -map_metadata 0 -id3v2_version 3 $OutputLocation | |
if ($DeleteOldFile -eq $True) | |
{ | |
Remove-Item $InputLocation | |
} | |
} | |
# For every file (recursively) in directory, find .flac files and call ConvertFile | |
foreach ($item in (Get-ChildItem -Path $Directory -Recurse)) | |
{ | |
if ($item.FullName.EndsWith(".flac")) | |
{ | |
ConvertFile -InputLocation $item.FullName | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment