Created
November 28, 2012 19:57
-
-
Save MrDOS/4163745 to your computer and use it in GitHub Desktop.
Check album art and ReplayGain tags of a hierarchical music library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Check through a hierarchical music library to verify that album art meets a | |
# minimum size or that music is ReplayGain-tagged. | |
# Usage: | |
# ./checkalbums.sh [-art] [-replaygain] | |
# If -art is given, verify album art size. If -replaygain is given, check for | |
# the existence of ReplayGain tags and add them if not present. | |
MINSIZE=600 | |
MINWIDTH=$MINSIZE | |
MINHEIGHT=$MINSIZE | |
if [ $# -eq 0 ] | |
then | |
echo "Usage: $0 [-art] [-replaygain]" 1>&2 | |
exit 1 | |
fi | |
if ! type "identify" 1>/dev/null 2>&1 | |
then | |
echo "ImageMagick not found!" 1>&2 | |
exit 2 | |
fi | |
if ! type "replaygain" 1>/dev/null 2>&1 | |
then | |
echo "ReplayGain not found!" 1>&2 | |
exit 2 | |
fi | |
if echo "$@" | grep -q "\-art" | |
then | |
echo Checking for album art... | |
art=`find . -type f -name *.jpg` | |
for album in */*/ | |
do | |
if ! echo "$art" | grep -q "./$album" | |
then | |
echo Couldn\'t find art for "$album"! | |
fi | |
done | |
echo | |
echo Looking for artwork that doesn\'t meet the minimum size... | |
echo "$art" | while read album | |
do | |
dimensions=`identify -format '%[fx:w] %[fx:h]' "$album"` | |
width=`echo $dimensions | cut -d ' ' -f 1` | |
height=`echo $dimensions | cut -d ' ' -f 2` | |
if [ "$width" -lt "$MINWIDTH" -o "$height" -lt "$MINHEIGHT" ] | |
then | |
echo "`echo $album | sed -e 's/^.\///'` (${width}x${height})" | |
fi | |
done | |
echo | |
fi | |
if echo "$@" | grep -q "\-replaygain" | |
then | |
echo Checking for the presence of ReplayGain tags... | |
for album in */* | |
do | |
replaygain -d "$album"/* | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment