#!/bin/sh

FLAC_PATH=$HOME/Music/FLAC/
OPUS_PATH=$HOME/Music/OPUS/

# Generate non-existent directories
fd -0td --base-directory=$FLAC_PATH -x mkdir -p $OPUS_PATH{}

# Transcode non-existent FLACs to OPUS
fd -t f -e flac --base-directory=$FLAC_PATH -x ffmpeg -loglevel 16 -n -i "$FLAC_PATH{}" -c: libopus -b:a 96k "$OPUS_PATH{.}.opus"

# Copy album covers
fd -t f -e jpg --base-directory=$FLAC_PATH -x cp "$FLAC_PATH{}" "$OPUS_PATH{}"
