Skip to content

Instantly share code, notes, and snippets.

@BinaryMuse
Created April 22, 2011 21:32
Show Gist options
  • Select an option

  • Save BinaryMuse/937728 to your computer and use it in GitHub Desktop.

Select an option

Save BinaryMuse/937728 to your computer and use it in GitHub Desktop.
Convert a directory (and subdirectories) full of .flac files to .mp3 using ffmpeg
require 'find'
def convertFile(path)
puts "Converting #{path}"
choppedSafeFilePath = path.chomp(File.extname(path))
`ffmpeg -i "#{choppedSafeFilePath}.flac" -ar 44100 -ab 128k -y "#{choppedSafeFilePath}.mp3" 2>/dev/null`
end
Find.find("/media/New Volume/song_directory") do |path|
if File.extname(path) == ".flac"
convertFile path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment