Skip to content

Instantly share code, notes, and snippets.

@jsanti
Created August 6, 2010 03:39
Show Gist options
  • Save jsanti/510795 to your computer and use it in GitHub Desktop.
Save jsanti/510795 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'mp3info'
series = { 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V"}
1.upto(5) do |i|
Dir.glob("Nivel #{i}/*.mp3").each do |entry|
dirname = File.expand_path(File.dirname(entry))
filename = File.basename(entry)
if lec_match = filename.match(/(\d{2})\.mp3$/)
lec_no = lec_match[1]
p "#{filename} ===> #{lec_no}"
Mp3Info.open(File.join(dirname,filename)) do |mp3|
mp3.tag.title = "Lektion #{lec_no}"
mp3.tag.album = "Serie #{series[i]}"
mp3.tag.artist = "Deustch Warum Nicht"
mp3.tag.tracknum = lec_no.to_i
end
File.rename(File.join(dirname, filename), File.join(dirname, "Serie #{series[i]} - Lektion #{lec_no}.mp3"))
else
p "ERROR with #{dirname}/#{filename}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment