Bandcamp Friday Purchase (an excuse to be Very Computer)
Fri 03 October 2025It's Bandcamp Friday and like any artist-respecting money haver, I bought some new music today. One thing I got was a discography of 42 albums that had 30 singles albums in it. Some real bangers in there, but my music collection is relatively small and 30 new albums with 1-3 tracks each will absolutely drown out the rest of my collection. Even the 12 EPs and LPs included in the rest of the discog add a substantial percentage all at once to my library.
So, in order to get them working in my Navidrome music directory to my liking, I ended up using bash pretty heavily.
First, to unzip them all at once, since even the single mp3 directories had been zipped, I ended up running:
for album in *.zip; do albdir="${album%.zip}"; mkdir "$albdir"; unzip -d "$albdir" "$zipfile"; done
This enumerates the .zip files, makes a new directory with the name of each minus the .zip part, and then unzips that file into its new directory. Neat!
For the next step, 2 of the singles were just mp3 files, but the rest of them were in their own directories. Luckily, they all had (Single) in the file and directory name. To get every directory with Single in the name into a single directory of the singles directory (Christ preserve us), I ran:
for file in *Single*; do mv "$file" Revengeday\ -\ Singles/; done
And now you know what artist I bought music from! Follow my lead, this is some solid cyperpunk techno!
Then, to pick the mp3s out of those directories and move them all into a single directory, I did this:
find . -iname '*.mp3' -type f -exec mv {} single\ Album/ \;
I didn't do this from the start because I wanted a directory with only directories and mp3s I'd be moving to be working from. Since I started with unzipping the 12 other albums too, I couldn't just treat everything in this directory as needing to be moved.
Onward, tho! Now I have a directory with 52 tracks in it, according to a wc -l. Some of these "singles" are actually a 1 and 2 track with a bonus track. Homie, that's an EP. Just call it an EP. Anyway, plenty of remixes too. The track titles have remix & collab info in them, so to keep the metadata cleaner, I wanted to change artist, album, and track # info on each track. The following worked:
tn=1 && for file in *.mp3; do id3v2 --TALB "Revengeday Singles" "$file"; id3v2 --TRCK $tn "$file"; id3v2 --TPE1 "Revengeday" "$file"; id3v2 --TPE2 "Revengeday" "$file"; tn=$((tn+1)); done
I ran it as a one-liner, but let's break it out into a multi-liner for clarity:
tn=1 # a mystery variable we'll need later (track number)
for file in *.mp3; do # list mp3 files in pwd
id3v2 --TALB "Revengeday Singles" "$file" # use id3v2 to change each file's Album info to the same album
id3v2 --TRCK $tn "$file" # use id3v2 to change track number to current counter
id3v2 --TPE1 "Revengeday" "$file" # flatten collab & remix info (sorry, artists, my library wasn't happy) to simply Revengeday
id3v2 --TPE2 "Revengeday" "$file" # same flattening, but for secondary artist tag
tn=$((tn+1)) # increment track number
done
To bring it all together, here's how you can unzip everything, move the Singles albums to the same place, extract the mp3s into a single 'album', and edit their metadata so they're all actually in one album:
#!/usr/bin/env bash
for zipfile in *.zip; do
exdir="${zipfile%.zip}"
mkdir "$exdir"
unzip -d "$exdir" "$zipfile"
done
for file in *Single*; do
mv "$file" Revengeday\ -\ Singles/
done
cd Revengeday\ -\ Singles
find . -iname '*.mp3' -type f -exec mv {} Revengeday\ Singles\ Album/ \;
cd Revengeday\ Singles\ Album
tn=1 # a mystery variable we'll need later (track number)
for file in *.mp3; do # list mp3 files in pwd
id3v2 --TALB "Revengeday Singles" "$file" # use id3v2 to change each file's Album info to the same album
id3v2 --TRCK $tn "$file" # use id3v2 to change track number to current counter
id3v2 --TPE1 "Revengeday" "$file" # flatten collab & remix info (sorry, artists, my library wasn't happy) to simply Revengeday
id3v2 --TPE2 "Revengeday" "$file" # same flattening, but for secondary artist tag
tn=$((tn+1)) # increment track number
done
After doing this, you'd have to manually clean up some Singles directories. I did this with an interstitial state where my Singles Album was actually called 'singles Album'. I'm never truly comfortable deleting files in a one-off script though, so I didn't completely automate it. But there you have it! A few lines of bash and you've got 30 zip files full of music unzipped, collated, and cleaned up into one album! All it took was years of experience to be comfortable taking a few whacks at the commands and remembering the find exec delimiters. Someday I'll remember!
Blu Blog