Bandcamp filename mangling
Apr. 17th, 2021 01:29 pmDanz aka Computer Magic aka Danz CM (current handle) aka Danielle "Danz" Johnson just posted their back catalogue on Bandcamp and I am both extremely happy and lighter of bank account. I downloaded their early EPs when they first posted them to the Internet for free download over a decade ago and have been looking for a way to pay money to them for this music that I have enjoyed so much. This finally gave me the opportunity to do so (I will not give money to iTunes or Spotify and their ilk, and want to have either physical media or at least downloaded digital media so I am not reliant on such services for access). It's also very nice that Bandcamp lets me choose what audio formats I want to download. I get FLAC (lossless) and MP3 (with V0 encoding for size).
https://computermagic.bandcamp.com/
Anyway, the issue is that the Bandcamp filenames do not match the format I maintain my library in. I've downloaded albums before and renamed all the files manually, but the last time I got a few albums (Nash the Slash, another of my favourite artists), I knuckled under and wrote a script to mangle the filenames into the format I like: "<track_number>-<artist>-<song_name>.<suffix>" (there's also some stuff I like to do with special characters and such, like use "+" when the artist or song name has a "-" in it that I included). It's called (unimaginatively) "fix_bandcamp_names.sh". I unzip the files downloaded from Bandcamp into a temporary directory, cd into it, and run the script. When I'm done with the track names and such, I rename the directory to "<artist>--<album_name>". For MP3s, I have another script ("relabelmp3s") that I pass in the release year, and run in the directory with the MP3 file that sets the MP3 meta information based on the song and album names (it uses the "id3tag" program). The process does a pretty good job for me (some hand-tweaking of filenames post-processing is sometimes necessary as it's just mindless text substitution for the most part). Here are the scripts, you are welcome to use them or adapt them as you see fit. Yes, I use regexp stuff, so it looks like I had a seizure while typing (or barfed ASCII onto the screen).
fix_bandcamp_names.sh:
— Jamie Zawinski
I leave you with one of my favourite Computer Magic videos (and one of my favourite videos of all time... it really resonates with me).
https://computermagic.bandcamp.com/
Anyway, the issue is that the Bandcamp filenames do not match the format I maintain my library in. I've downloaded albums before and renamed all the files manually, but the last time I got a few albums (Nash the Slash, another of my favourite artists), I knuckled under and wrote a script to mangle the filenames into the format I like: "<track_number>-<artist>-<song_name>.<suffix>" (there's also some stuff I like to do with special characters and such, like use "+" when the artist or song name has a "-" in it that I included). It's called (unimaginatively) "fix_bandcamp_names.sh". I unzip the files downloaded from Bandcamp into a temporary directory, cd into it, and run the script. When I'm done with the track names and such, I rename the directory to "<artist>--<album_name>". For MP3s, I have another script ("relabelmp3s") that I pass in the release year, and run in the directory with the MP3 file that sets the MP3 meta information based on the song and album names (it uses the "id3tag" program). The process does a pretty good job for me (some hand-tweaking of filenames post-processing is sometimes necessary as it's just mindless text substitution for the most part). Here are the scripts, you are welcome to use them or adapt them as you see fit. Yes, I use regexp stuff, so it looks like I had a seizure while typing (or barfed ASCII onto the screen).
fix_bandcamp_names.sh:
#!/bin/bash for i in *.mp3 *.flac *.pdf; do mv "$i" `echo "$i" | sed 's/ /_/g'`; done for i in *.mp3 *.flac; do mv $i `echo $i | sed 's/\(^.*\)_-_.*_-_\([0-9]*\)_\(.*$\)/\2-\1-\3/'`; done for i in *.mp3 *.flac; do mv $i `echo $i | sed 's/_-_/+/g'`; donerelabelmp3s:
#!/bin/bash if [[ $# != 1 ]]; then echo "usage: `basename $0`"Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems."" exit 1 fi for i in *.mp3 do id3tag -s"`echo ${i%.mp3} | cut -d- -f3 | tr '_' ' ' | tr '+' '-' | tr '=' ':'`" -a"`echo $i | \ cut -d- -f2 | tr '_' ' ' | tr '+' '-' | tr '=' ':'`" -A"`basename $PWD | cut -d- -f3 | \ tr '_' ' ' | tr '+' '-' | tr '=' ':'`" -y $1 -t`echo $i | cut -d- -f1` "$i" done
— Jamie Zawinski
I leave you with one of my favourite Computer Magic videos (and one of my favourite videos of all time... it really resonates with me).