Thursday, October 28, 2010

Backup the Pod

I have found it very hard to backup the music from the iPod to the system. Especially when the music inside is encrypted in some weird fashion. To see this go to /Volumes/Ipod/iPod_Control/Music from the command line and look at the contents inside. They are categorized in a weird fashion and make no sense.

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 !!!!

Monday, October 25, 2010

Mac on Lenovo

Franki just did the most amazing thing by installing OS X - 10.6 on a Lenovo. He tried out with Pally Sir's CD at first but that did not go well. I would confer with him and convince him to write about the set up and hacks here. Stay Tuned.