Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created October 18, 2011 04:46
Show Gist options
  • Save res0nat0r/1294625 to your computer and use it in GitHub Desktop.
Save res0nat0r/1294625 to your computer and use it in GitHub Desktop.
Generate music video .nfo files for XBMC
#!/usr/bin/env ruby
Dir.glob('**/*.*').each do |file|
nfo = File.dirname(file) + "/" + File.basename(file).split('.').first + ".nfo"
genre, artist, album = File.dirname(file).split('/')
title = File.basename(file).split('.').first.gsub(/_/, ' ').gsub(/.*?-/, '')
next if File.exists?(nfo)
file = File.open(nfo, 'w')
file << <<EOF
<musicvideo>
<artist>#{artist}</artist>
<title>#{title}</title>
<album>#{album}</album>
<genre>#{genre}</genre>
</musicvideo>
EOF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment