Skip to content

Instantly share code, notes, and snippets.

@alwalker
Last active December 23, 2023 18:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alwalker/3063656 to your computer and use it in GitHub Desktop.
Save alwalker/3063656 to your computer and use it in GitHub Desktop.
Convert a folder of flac files to 192k variable bit rate mp3's. Takes Artist, Album, Track #, Title, Genre, Date, and Album Art tags with it.
$files = get-childitem F:\Work_Area\Music\Raw *.flac -rec
foreach ($file in $files)
{
$artist = metaflac $file.fullname --show-tag=ARTIST
$artist = $artist.split("=")[1]
$title = metaflac $file.fullname --show-tag=TITLE
$title = $title.split("=")[1]
$album = metaflac $file.fullname --show-tag=ALBUM
$album = $album.split("=")[1]
$genre = metaflac $file.fullname --show-tag=GENRE
$genre = $genre.split("=")[1]
$tracknumber = metaflac $file.fullname --show-tag=TRACKNUMBER
$tracknumber = $tracknumber.split("=")[1]
$date = metaflac $file.fullname --show-tag=DATE
$date = $date.split("=")[1]
if(!(Test-Path "F:\Work_Area\Music\sd\$artist\$album"))
{
New-Item "F:\Work_Area\Music\sd\$artist\$album" -type directory
}
$mp3 = "F:\Work_Area\Music\sd\$artist\$album\" + $file.tostring().Replace(".flac", ".mp3")
$wav = $file.fullname.Replace(".flac", ".wav")
flac -d $file.Fullname
metaflac $file.Fullname --export-picture-to=cover.jpg
lame -V2 --add-id3v2 --pad-id3v2 --ignore-tag-errors --nohist --ty $date --tt $title --ta $artist --tl $album --tn $tracknumber --tg $genre --ti cover.jpg $wav $mp3
Remove-Item $wav
Remove-Item cover.jpg
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment