Civilized Bandcamp file unzipping

Here’s a script that’s handy for unzipping stuff you download from Bandcamp.

Bandcamp gives you zip files that contain no directory structure. So, the files just unzip to whatever directory you’re in. I have found that to get messy, and I now like an artist-dir/album-dir structure, like I’m in the year 2000.

Here’s a script I wrote to unzip Bandcamp zip files into such a structure. It uses the naming scheme of the zip file (<artist name>-<album name>) to determine the appropriate directory names.

#!/bin/bash

for file in *.zip
  do
    filename="${file%.*}"
    # Filenames can't contain /. So, I wonder
    # what Bandcamp would do if they had AC/DC?
    unzippath=$(echo "$filename" |sed -e 's/ - /\//')
    mkdir -p "$unzippath"
    unzip "$filename" -d "$unzippath"
  done

It will run on all of the zip files in the working directory. You’ll end up with your mp3 files in directory structures like Chaucerian Myth/The Canterbury Tales now.


Here, we’re about to drift away from that tiny script into background story space! I feel like a guy that responds to “Where is the nearest gas station?” with a long explanation of local zoning policy and their own personal journey away from fossil fuels to a house powered entirely with solar panels. (I actually would like solar panels, BTW.)

Unlike that guy, however, there is no way I’ll notice if you just close the tab now!


This has come up because I’ve been increasingly enjoying Bandcamp over the last few years, but now I’m all in on them.

I’ve usually used their streaming service, but lately I’ve been downloading albums from them and importing them into Plex to play. (I like it because lets me stream from my Raspberry Pi at home to my phone. The Bandcamp app also lets you stream to your phone but only with music you’ve bought on Bandcamp.)

At first, I thought I’d dump all of my files into one directory and let Plex use ID3 tags to organize them, but you still have to get into the files sometimes, and a 4,000-file directory is total hell. Via Bandcamp purchases and CD rips (weird, I know), this pile is growing again after being frozen for half a decade and needs a little structure.

I think I like this way of listening to and acquiring music, as backwards as it sounds, because I tend to consider each album more fully and give each one more of a chance, either because I bought it directly or I once bought it long ago and now have put in the work to rip a CD. And in the cases when I buy from a label-less artist, I provide magnitudes more financial compensation to the artist than I would via any streaming service.