Feeds:
Posts
Comments

Renaming MP3 Files

So everyone’s got a bunch of MP3 files stashed away in a folder. Chances are, many of them don’t have proper filenames, and look something like:

C:\Music\Unknown Artist\Unknown Album\QSCD.mp3

However, there is hope – especially for aspiring programmers. Your mp3 files may already have the track name, artist and album details stored in ID3 tags – if you’re able to see this information in iTunes/Windows Media Player/Winamp.

This problem started bugging me a while ago while I was switching from iTunes to Winamp, and my appetite for a suitable Computer Science activity growled eagerly. I thought of trying a Java-based solution – it went somewhat like this:

  1. Find a free (& maybe open source) Java ID3 reader package
  2. Learn how to enumerate files in a directory and pick out MP3s
  3. String this knowledge together

The solution was pretty simple:

  1. The JID3.jar package has support for reading and writing to ID3 tags – both v1 and v2 and it’s free-ish licence suted me just fine. They had a couple of code samples on the site too.
  2. I remembered seeing an example of this a couple of source code files ago, and googled. Apparently it’s a simple matter of:
    File folder = new File("C:\Music\");
    File[] subFiles =  folder.listFiles();
    
  3. The final utility turned out to be pretty simple. At the heart of the code was this tag-reading snippet:
MP3File mp3file = new MP3File(file);
ID3Tag[] id3Tags = mp3file.getTags();
String title = null;
for (ID3Tag tag : id3Tags)
{
if (tag instanceof ID3V1_0Tag)
{
System.out.println("ID3v1: " + file.getName());
ID3V1_0Tag tag1 = (ID3V1_0Tag) tag;
if ( (title = tag1.getTitle()) != null)
return title;
} else if (tag instanceof ID3V2_3_0Tag)
{
System.out.println("ID3v2_3: " + file.getName());
ID3V2_3_0Tag tag23 = (ID3V2_3_0Tag) tag;
if ( (title = tag23.getTitle()) != null)
return title;
}
}

But that was far from the end of the project. I wanted this thing to run through my entire music folder and apply itself to every “.mp3” file. As a bonus, it needed to remove track numbers from files like “01 Sage of Lamberene.mp3”. A most pleasurable evening later, it was finished. “public class MP3TagFileRenamer” even featured a recursive method to tackle subfolders within subfolders.

For those who’d like to tinker with it, here’s the source code. A bit messy, but legible and modular nonetheless. Legal Notice: Play all you want with it – but I am not liable for any (potential) damages incurred.

Future updates? The next step would be renaming folders to match the ID3 tags, the media players can take it from here…

Enjoy! 😀

Advertisements

Most of us have heard of wireless LANs, and use them for everything from Apple’s App Store to Zoho Office without a second thought. (Web browsing? What a ridiculous concept in the modern day!) What most of us don’t know is that our data may be at risk.

I recently took a walk on Dubai’s the famed Sheikh Zayed Road with my laptop’s wi-fi active. Using Kismet, a wireless network scanning tool, I was able to discover a total of 1114 wireless networks, over a 1.3 km stretch, at ground level only. If that didn’t come as a shocker, try this: half of them were _blatantly_ insecure.

overall-wireless-stats

To be precise, 558 / 1114 wireless networks were wide open to nefarious war-drivers and piggy-backers.You could see them on a standard issue Windows laptop – without the little yellow lock that indicates a password or some level of security. Thee guys, and their internet connections, printers and networked computers, were essentially unprotected from outsiders.

From the statistics you’d probably think that the other half are doing alright. In fact, the 29% “WEP” are not. WEP stands for Wired Equivalent Privacy, and that it is certainly not. Flaws have been discovered in the error-checking algorithms used to encrypt and decrypt the invisible information streams, and exploiting them takes a mere 5-10 minutes on a wireless network with a reasonable level of traffic. Your average Windows XP laptop user looking for a quick email/Facebook check is probably deterred, but certainly not your Linux-wielding computer geek ( hint, hint 😉 ). In short, WEP.

The only way to be reasonably secure a wireless network, in a cost-effective manner, is to enable WPA (Wi-Fi Protected Access), with AES, on your home/small office wireless router. As always, picture provided for your convenience:

Portions of this image attributable to Linksys/Cisco Systems.

Wireless LANs are incredibly useful and adaptable, but if they are not suitably secured they quickly become a liability.

For obervations/more info, use the shout-box below. Stay safe!

College Applications are long and difficult. The essays stretch to infinity and the activity forms are absurdly mathematical (C’mon! How many hours/week and weeks/year do you spend doing xyz?). However, deep within the process, beyond the sense of accomplishment on Dec 31, was… an understanding of who I really am.

Take this essay topic for example (Exact wording modified to throw off pesky college applicant-cum-Googlers:))

You have just written your 301-page autobiography. Please give us page 218.

The sheer amount of thought required to even attempt a response is mind-blowing. You have to think not only of who you are at the moment, but also of who you want to be in the future, and why you want to be the person you have outlined. Granted – it was an optional admission essay topic from one of America’s elite colleges, but there’s no doubt that many high-school seniors, myself included, emerged from the shells of shyness and expressed our egos to our hearts’ content.

This topic, as well as many others, effectively captured the concept of putting yourself, your accomplishments, goals, and dreams, on paper for the admissions officers. To get to know me from this first post, dear Reader, I ask that you read my autobiographical attempt.

‘Till next time,

§

Stay Tuned…

This blog is under construction.

Striped Yellow-and-White Cone

The image above is courtesy of the best video player on the Internet, VLC.

Enjoy the wait – it won’t be long!