Skip to content

Instantly share code, notes, and snippets.

@micahbrich
Created May 21, 2011 23:40
Show Gist options
  • Save micahbrich/985006 to your computer and use it in GitHub Desktop.
Save micahbrich/985006 to your computer and use it in GitHub Desktop.
Batch convert flac to mp3, with metadata, using ffmpeg
Dir.glob("*.flac").each do |f|
flac = "./#{f.gsub(' ', '\ ')}"
mp3 = "./#{f.gsub(' ', '\ ').chomp('.flac')}.mp3"
system("ffmpeg -i #{flac} -map_meta_data #{mp3}:#{flac} #{mp3}")
end
Dir["*.mp3"].each do |file|
puts "\rConverting #{file}..."
file = file.chomp(".mp3")
`ffmpeg -i '#{file}.mp3' '#{file}.wav'`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment