Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0341c7693e
Fetching contributors…

Cannot retrieve contributors at this time

executable file 48 lines (44 sloc) 1.209 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/usr/bin/env ruby
require 'fileutils'

#recursively convert everything
def convert(src, dest, depth = "")
#go through everything in the path
Dir.foreach(File.join(src, depth)) do |filename|
#if it's a directory
full_src = File.join(src, depth, filename)
full_dest = File.join(dest, depth, filename)
full_dest = "#{full_dest[/(.*)\.ogg/,1]}.mp3"
if Dir.exists?(full_src) then
if !((filename == ".") || (filename == "..")) then
puts full_src
if !Dir.exists?(full_dest) then
FileUtils.mkdir full_dest
end
convert(src, dest, File.join(depth, filename))
end
#else if its a file
elsif File.ftype(full_src) == "file" then
#only convert oggs
if File.extname(filename) == ".ogg" then
#check that it doesn't exist
if !File.exists?(full_dest) then
puts full_src
`ffmpeg -i "#{full_src}" -ab 192k "#{full_dest}"`;
end
end
end
end
end

#check command line args
if ARGV.size != 2 then
puts "Usage: music_library_converter.rb <source> <destination>"
exit
end

#do the initial setup and then convert
src = ARGV[0]
dest = ARGV[1]

puts "Converting from #{src} to #{dest}"
if !Dir.exists?(dest) then
FileUtils.mkdir dest
end
convert(src, dest)
Something went wrong with that request. Please try again.