dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit d7e8e2b6cd0f0647a782728200f358057e8e2728
parent 0baabbf42ad271b314d489f08c068f88866f38de
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 17 Oct 2019 15:47:00 +0200

Add cd rip script using cdio, ffmpeg, and id3tag

Diffstat:
A.local/bin/rip-audio-cd.sh | 42++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+), 0 deletions(-)

diff --git a/.local/bin/rip-audio-cd.sh b/.local/bin/rip-audio-cd.sh @@ -0,0 +1,42 @@ +#!/bin/sh +set -e + +help() { + echo "$0 [FORMAT]" + echo "uses cdio, ffmpeg, and id3tag to rip and encode audio cd tracks to FORMAT." + echo "FORMAT is 'mp3' by default" +} + +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + help + exit 0 +fi + +cddbinfo=$(cdio cddbinfo) +artist=$(printf "%s" "$cddbinfo" | sed 1q | sed 's/ \/.*$//') +album=$(printf "%s" "$cddbinfo" | sed 1q | sed 's/.* \/ //;s/(.*$//') + +format="${1:-mp3}" +outdir="/home/music/${artist}/${album}/" + +echo "format: $format" +echo "artist: $artist" +echo "album: $album" +echo "output dir: $outdir" + +mkdir -p "$outdir" +cd "$outdir" +cdio cdrip + +for f in *.wav; do + track=$(echo "$f" | sed 's/track\([0-9]*\).wav/\1/') + i=$(echo "$track" | sed 's/^0//') + title=$(printf "%s" "$cddbinfo" | grep " $i " | sed 's/.*[0-9] //') + fout="${track} ${artist} - ${title}.${format}" + ffmpeg -i "$f" -vn -ar 44100 -ac 2 -ab 192k "$fout" + id3tag --artist="$artist" --album="$album" --song="$title" --track="$track"\ + "$fout" +done + +rm ./track*.wav +cd -