Poking around with Python

With my usual caveat that I’m not primarily a programmer (and thus I’m sure there are better ways to do things), I thought I’d share a quick python script I put together.

For some context: I’ve been a long-time subscriber to the KEXP Song of the Day podcast, and I’m not prone to deleting songs after listening to them, which means that podcast is up to ~3000 songs, all sitting in a single folder. My car stereo has usb support, so ostensibly I can dump the whole folder onto a usb key and play it all while driving. Unfortunately, the car stereo can’t handle a folder with that many songs, so I needed to split it into smaller subfolders of around 100 songs each.

Now, I could do this manually (and did, the first time around), but I wanted an excuse to experiment with some scripting, and also wanted to fix some of the song titles (sometimes the ID3 title tag would include the artist, other times not). Doing some searching around, it seems like there’s a pretty solid python library for reading and manipulating ID3 tags, so I decided to use that.

You can see the resulting script here. It does two things: copy the files into subfolders (in a somewhat arbitrary order, which I may try to fix later), and then compare the ID3 artist tag to the ID3 title tag, and if the title tag starts with the same thing as the artist tag, strip the artist name out of the title tag (since it’s redundant, and meant the title was often cut off from being seen on the stereo’s display).

If it’s useful for you, cool! If not, I figured I’d at least share what I’ve been puttering with lately.

1 thought on “Poking around with Python

Comments are closed.