CLI FLAC Conversion with SoX
As I remember it, Bandcamp downloads used to come in 16bit or 24bit FLAC. It seems you don't have this choice anymore; we'll make that conversion ourselves with Sound eXchange for the sake of conserving storage space.
- Install SoX via homebrew:
brew install soxcdinto your source FLAC album folder:
cd /Downloads/your-flac-album- Convert.
This snippet will create an identically-named folder with (16-bit) appended to the end, convert the FLAC files from 24-bit to 16-bit, then finally place the converted FLAC files in the new folder:
# macOS zsh — run inside the folder with your FLACs
base="$(basename "$PWD")"
outdir="${base} (16-bit)"
mkdir -p "$outdir"
for f in *.[Ff][Ll][Aa][Cc]; do
sr=$(soxi -r "$f")
case "$sr" in
44100|48000)
# Reduce bit depth to 16-bit, keep existing sample rate
sox -S "$f" -R -G -b 16 "$outdir/$f" dither
;;
88200|176400)
# Downsample to 44.1 kHz with high-quality, linear-phase resampler
sox -S "$f" -R -G -b 16 "$outdir/$f" rate -v -L 44100 dither
;;
96000|192000)
# Downsample to 48 kHz with high-quality, linear-phase resampler
sox -S "$f" -R -G -b 16 "$outdir/$f" rate -v -L 48000 dither
;;
*)
echo "Skipping $f (unsupported sample rate: $sr)"
;;
esac
doneHere's the full breakdown of this command:
Detects the current folder name and creates an output directory named "[folder name] (16-bit)".
- Iterates over all FLAC files in the folder, case-insensitively.
- Reads each file's sample rate using soxi.
If the sample rate is 44.1 kHz or 48 kHz: converts to 16‑bit with dithering, keeping the original sample rate.
If the sample rate is 88.2 kHz or 176.4 kHz: downsamples to 44.1 kHz with a very‑high‑quality, linear‑phase resampler, then converts to 16‑bit with dithering.
If the sample rate is 96 kHz or 192 kHz: downsamples to 48 kHz with a very‑high‑quality, linear‑phase resampler, then converts to 16‑bit with dithering.
- Uses -G to guard against clipping; -S to show warnings; -R for consistent defaults.
Writes outputs into the "[folder name] (16-bit)" directory with the same filenames as the originals.
- Skips any files with unsupported sample rates and prints a message indicating the rate.
I like to use Spek to view the audio files and compare the difference in quality.
Before:

After:

This is strictly for my personal reference—I won’t be going into any further details on SoX. May any wanderers find this useful, though!
Back
Head back to writing and explore more posts.
