I was done with those softwares which let me backup only 100 songs or so. Therefore I tried what I could do programmatically to get those lost song names (file names) right.
I went through those Meta Data accessing libraries written by brilliant people and managed to find a good one. The Library had very much of what I wanted. It could access those meta tags like title, artist and album. All I needed was a API thing for Ruby (I love Ruby :P ). TagLib also had language bindings for the ruby language !
You need to download the package and then run
./configure
make
sudo make install
make clean
Thats it ! You have installed the C stuff. Now do a
sudo gem install rtaglib
for the ruby package. The help docs are here. Try it out in irb and you will be pleased.
Now for the backup. I did a
cp -r **/*.mp3 /My/HOME/NEWDIR/.
to get all the encoded mp3s in a directory from the iPodControl/Music directory.
Now came the ruby code ....
require 'rubygems'
require 'tagfile/tagfile'
f = Dir.glob('/My/HOME/NEWDIR/*mp3')
f.each{|i|
begin
tag=TagFile::File.new(i)
nn = i.split('/')
nn[-1]=(tag.title.to_s + '-' + tag.artist.to_s + '-' + tag.album.to_s).gsub('/','') + '.mp3'
nn=nn.join('/')
p 'Renaming file '+i+ ' to '+ nn
File.rename(i,nn);
sleep 2
rescue
print "An error occurred: ",$!, "\n"
break
end
}
This gave some warnings and stuff but generally did the trick for me. I now have an organized view of my files !!!!
No comments:
Post a Comment