MythTV “du” – find out what shows take up the most space
I was wondering where all my space was going in MythTV recently, so I figured I’d whip up a quick “du” that will give me a per-title breakdown of usage.
It assumes you have just the one storage area for recordings.
#!/bin/bash
STORAGEPATH='/mnt/storage/Media/MythTV/recordings'
DBPASS='abc123'
QUERY="SELECT basename,title FROM recorded ORDER BY title;"
MYSQL="mysql -u mythtv --password="$DBPASS' mythconverg"
SIZE=0
COUNTING_FOR=''
echo $QUERY | $MYSQL | tail -n +2 | while read BASENAME TITLE; do
if [ "$COUNTING_FOR" != "$TITLE" -a "$COUNTING_FOR" != "" ]; then
echo "${SIZE} MB - $COUNTING_FOR"
SIZE=0
fi
COUNTING_FOR="$TITLE"
SIZE=$(($SIZE + `du -m "$STORAGEPATH/$BASENAME"|cut -f1`))
done
Use it like this:
./mythtv_du.sh|sort -nr|head -20