mirror of
https://codeberg.org/frosty/dotfiles.git
synced 2024-09-19 11:47:09 -04:00
25 lines
668 B
Plaintext
25 lines
668 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
SRC_DIR="$HOME/music"
|
||
|
DEST_DIR="/run/media/$USER/F967-1B77/Music"
|
||
|
|
||
|
die() {
|
||
|
printf '%s: %s\n' "${0##*/}" "$1" >&2
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
# Check source and destination directories
|
||
|
[ -d "$SRC_DIR" ] || die "no such directory: $SRC_DIR"
|
||
|
[ -d "$DEST_DIR" ] || die "no such directory: $DEST_DIR"
|
||
|
|
||
|
# Sync directories and artwork
|
||
|
rsync -a --include '*/' --exclude '*.flac' "$SRC_DIR/" "$DEST_DIR/"
|
||
|
|
||
|
# Transcode audio
|
||
|
find "$SRC_DIR" -type f -name '*.flac' | while read -r src_file; do
|
||
|
rel_path="${src_file#"$SRC_DIR"/}"
|
||
|
dest_path="$DEST_DIR/${rel_path%.*}.opus"
|
||
|
|
||
|
[ -f "$dest_path" ] || ffmpeg -nostdin -i "$src_file" -c:a libopus -b:a 96k "$dest_path"
|
||
|
done
|