Tuesday, August 05, 2008

Using Powershell to Query and Integrate MP3 Album Art

I've been trying to update my mp3 collection with album art since I got the P2. There are many tools out there that allow you to achieve this, but none that provide an easy and flexible way to automate the whole tagging process. That's why I wrote a quick and dirty Powershell script to do the job for me. Plus, it gives me a chance to play around with Powershell.

How it works:
The script can be executed in the following manner:
.\Mp3AlbumArt.ps1 .\mp3\*def*.mp3
.\Mp3AlbumArt.ps1 .\mp3\*\*.mp3
(recurse through sub folders)

The only parameter takes in the paths of the files that need to be processed. The script uses Greg Keogh's excellent NTag library for integrating the album art into the ID3 Tag. The album art itself is retrieved by querying the Amazon Web Service using the Artist and Album Tags. Obviously it doesn't work very well if the Meta tags are not set up properly.

Some assembly required:
You would need to register for an Amazon Web Service Account to get an key to query the service. Replace your key in the commented area to get stared.

I was in a rush to get something working so didn't spend too much time error handling or on any best practices. As I gain more experience with powershell, I will eventually re-write this script to take advantage of powershell functionality. But for now it serves is purpose.



Comments and constructive criticism appreciated.

No comments: