Recover your iPod playlist within seconds

I had to leave for Goa the other day and I was packing my bare essentials when I came across my age old forgotten iPod. Finding it out of blue was a bliss and I decided to take it along. I put it on charge and it was ready to rock.

2015-08-30I never realized what wonder old playlists can do. Listening to those old tracks I felt as if I was transported back to those good old carefree college days. After returning from Goa I decided to export those tracks to my computer, however there was an issue. We all know for some reason Apple renames music files and rearrange them in random folders. This makes it impossible to figure out which file corresponds which track.

Here take a look:

ipod files list

These are all random filenames. However to my relief these files were not encrypted and their ID3 tags were still intact. That meant all I needed to do was rename these files and I was good to go.

However given the size of my playlist (6.5 GB) there was no option to do this manually. So I wrote a little script that could help me out.


My script goes through these files, collecting their ID3 tags, maintaining a hash and finally copying these files over user provided destination to respective folders based on album name and the file itself is renamed on track title. Running the script restored back my playlist within 105 seconds. Here’s the benchmark:

0.160000 7.470000 7.630000 (105.228952)

And this is how my playlist looks now on my file system:

Selection_007 Selection_008

Here is the source code:

Feel free to star, fork, follow or contribute on GitHub. 🙂

Project Euler, ruby

Project Euler in Ruby

I recently started solving project Euler. I am using Ruby to solve these problems. My aim is to get results in optimum time. I try refraining myself from using brute force however I have used them couple of places where the sample data was limited and it did not make any considerable difference in performance.


In the process I also tried implementing a few mathematical algorithms like – Fermat’s Factorization and Quadratic Sieve wherever necessary. Its a great experience solving these problems. Given the nature of these problems it demands you to be intelligent in your approach. Many times its quite tempting to use brute force and I did that too (ended up restarting my crashed laptop).

And boy! its fascinatingly addictive. I’ve been digging wiki for countless algorithms, analyzing their pros and cons and selecting them accordingly for my solution – and not to mention coding them.

As Project Euler discourages posting answers online, I won’t be posting answers however I will be sharing my solutions. In the end of each solution I have posted Ruby Benchmark score calculated on my system.

Here’s the link to my GitHub repository:

Its a work in progress, so feel free to fork it, star it and collaborate to make it better.

Cheers! 🙂