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 697e8fcf16ed9f9545d57c1966b27a344921c6e3
parent 25e443f13a669fcdb19eccc489df4e54aced5b1e
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sat, 11 Jul 2020 16:06:26 +0200

Rewrite to preserve order of files specified by arguments

Diffstat:
M.local/bin/burn-audio-cd.sh | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/.local/bin/burn-audio-cd.sh b/.local/bin/burn-audio-cd.sh @@ -2,39 +2,36 @@ set -e help() { - echo "$0 FILES" - echo "converts FILES to wav and burns as an audio cd" - echo "requires lame, mpg123, faad2, and cdrtools" + printf 'usage: %s file ..' "${0##*/}" + echo "converts each FILE to wav and burns as an audio cd" + echo "requires ffmpeg and cdio/cdrecord" } -if [ $# -lt 1 ]; then +if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then help exit 1 fi -if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then - help - exit 0 -fi - -# convert to mp3 +# convert to wav +i=1 +outdir="$(mktemp -d)" for f in "$@"; do - extension="${f##*.}" - outwav="$(basename "$f" "$extension")wav" + outwav="$(printf '%s/%04d_%s' "$outdir" "$i" "$(basename "${f%.*}.wav")")" if [ -e "$outwav" ]; then - echo "$outwav exists, skipping..." + printf '%s exists, skipping...\n' "$outwav" else - ffmpeg -i "$f" "$outwav" + ffmpeg -i "$f" -c:a pcm_s16le -ac 2 -ar 44100 "$outwav" fi + + i=$(( i + 1 )) done # burn wav as audio cd if type cdio >/dev/null 2>&1; then - doas cdio tao -a -s auto ./*.wav - cdio eject + doas cdio tao -a "$outdir"/*.wav && cdio eject else - cdrecord -v -pad speed=1 -dao -swab ./*.wav + cdrecord -v -pad speed=1 -dao -swab "$outdir"/*.wav fi -rm ./*.wav +rm -rf "$outdir"