From ff57c6bf39ac5f172b8f59ac0904a247574ff5ce Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sat, 28 Mar 2015 10:40:27 -0700 Subject: [PATCH] add albumize.sh to create albums Signed-off-by: Colin Patrick McCabe --- albumize.sh | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) create mode 100755 albumize.sh diff --git a/albumize.sh b/albumize.sh new file mode 100755 index 0000000..d3f1496 --- /dev/null +++ b/albumize.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +die() { + echo $@ + exit 1 +} + +DIR="${1}" +[ x"${DIR}" == x ] && die "You must supply a directory to albumize" + +# Check for invalid files +find "$DIR" -not -name '*.mp4' | while read $FILE; do + die "Found invalid file $FILE" +done + +# Convert files to mp3 +for FILE in "${DIR}"/*.mp4; do + mp4-to-mp3.sh "${FILE}" || die "mp4-to-mp3.sh ${FILE} failed" + BASE="$(dirname "${FILE}")/$(basename "${FILE}" .mp4)" + mv -f "${BASE}.mp4.mp3" "${BASE}.mp3" || \ + die "failed to rename ${BASE}.mp4.mp3 to ${BASE}.mp3" +done + +NUM_MP3=$(find "$DIR" -type f -name '*.mp3' | wc -l) +NUM_NON_MP3=$(find "$DIR" -type f -not -name '*.mp3' | wc -l) +[ $NUM_MP3 -eq $NUM_NON_MP3 ] || die "found $NUM_MP3 mp3s, \ +but $NUM_NON_MP3 non-mp3 files." + +# Remove non-mp3 files +rm "${DIR}/"*.mp4 + +# Add id3 labels to files +tagger.py "${DIR}" -- 1.6.6.rc1.39.g9a42