All pastes #1046722 Raw Edit

Stuff

public shellscript v1 · immutable
#1046722 ·published 2008-06-13 03:47 UTC
rendered paste body
#! /bin/bashTAGDIR="$1"declare -a albumArraydeclare -a artistArraydeclare -a yearArraylet num=0##first, test for subdirectories and fail if they are detectedif `ls $TAGDIR/*/ > /dev/null 2>&1`; then 	echo "Subdirectories detected! If this is a multi-disc album, you must create it manually."	exit 1fiFILE=$( find $TAGDIR -iname *.flac | head -n 1 )EXT=$( echo ${FILE##*/*.} )##now, read the album tags for each file into an array elementfor i in `metaflac --show-tag=album "$TAGDIR"/*.$EXT | sed -e 's/.*ALBUM/ALBUM/g' -e 's/ /,#,#,#/g'`; do	albumArray[$num]=$i	((num++))	done##now, make sure each element in the array is the same, and fail if they aren't.num=0while [ "$num" -lt "$((${#albumArray[@]}-1))" ]; do	if [ "${albumArray[num]}" != "${albumArray[num+1]}" ]; then		echo "Files have different values for albums. Sorry, upload manually or fix your tags"		exit 1	fi	((num++))done##set album variable and fail if there is no album valueALBUM=`echo ${albumArray[0]} | sed -e 's/,#,#,#/ /g' -e 's/ALBUM=\(.*\)/\1/g'`if [[ "a$ALBUM" = "a" ]]; then	echo "No album detected.  Tag your files properly!"	exit 1fi##now read artist informationnum=0for i in `metaflac --show-tag=artist "$TAGDIR"/*.$EXT | sed -e 's/.*ARTIST/ARTIST/g' -e 's/ /,#,#,#/g'`; do        artistArray[$num]=$i        ((num++))done##now check to make sure artist information is the samenum=0while [ "$num" -lt "$((${#artistArray[@]}-1))" ]; do        if [ "${artistArray[num]}" != "${artistArray[num+1]}" ]; then		if [[ "${artistArray[num]}" = "ARTIST=" ]]; then			echo "No value for Artist detected, tag your album properly!"			exit 1		fi		ARTIST="Various Artists"		break	else		ARTIST=`echo ${artistArray[0]} | sed -e 's/,#,#,#/ /g' -e 's/ARTIST=\(.*\)/\1/g'`        fi        ((num++))done##now, read the year tags for each file into an array elementnum=0for i in `metaflac --show-tag=date "$TAGDIR"/*.$EXT | sed -e 's/.*DATE/DATE/g' -e 's/ /,#,#,#/g'`; do	yearArray[$num]=$i	((num++))	done##now, make sure each element in the array is the same, and fail if they aren't.num=0while [ "$num" -lt "$((${#yearArray[@]}-1))" ]; do	if [ "${yearArray[num]}" != "${yearArray[num+1]}" ]; then		echo "Files have different values for years. Sorry, upload manually or fix your tags"		exit 1	fi	((num++))done##set year variable and fail if there is no valueYEAR=`echo ${yearArray[0]} | sed -e 's/,#,#,#/ /g' -e 's/DATE=\(.*\)/\1/g'`if [[ "a$YEAR" = "a" ]]; then	echo "No year detected.  Tag your files properly!"	exit 1fiFORMAT="FLAC"BITRATE="Lossless"mktorrent --a google.com -p --output=/home/oorza/Desktop/torrent.torrent $TAGDIR