iTunes Album List in Perl
This winter I took a course called System Software. In it, we learned a neat programming language called Perl. Perl was handy for that class because it happens to be very good at parsing text, and we used it to write a simple compiler. Being the pragmatic kind of person that I am, I immediately began to think of ways to use this new found skill, and the opportunity arose in a rather roundabout way.
You see, I have what I'd describe as a fairly large collection of music (roughly 18.6 days worth according to iTunes). This sometimes causes problems when I'm out shopping for CDs and I can't quite recall which ones I already own. iTunes is able to export a list of your music as an XML document, but you end up with a large unwieldy file with roughly 15 lines per song.
The solution: create a small Perl script to go through every line of this gigantic XML document and create a list of albums matched with artists. The result of my code monkeying is in the box below. Is the script terribly well written? Not especially. Did my album problem really need solving that badly? Not particularly. Was this a good excuse to play around with Perl a bit? Damn right. Enjoy.
The result should look something like this. If you'd like to try this program out, but don't have the experience to run it in the command prompt, here's a summarized guide with some helpful links:
- If you're running Windows, you'll need to download a Perl interpreter such as ActivePerl. If you're running Linux, it's built in.
- Open up a simple text editor (NodePad, WordPad, TextPad), then save the code from the above box as "albumlister.pl". Open iTunes, go to File > Export Library and save it as "library.xml" in the same directory as the Perl code.
- Open up the command prompt and switch over to the directory where you saved the Perl code (helpful guide here).
- Type in the following to run the program: "perl albumlister.pl library.xml". Your album list will be stored in a file called "Album List.txt" in the same directory.