This is really useful if your in a predicament where you get a show that has constant releases…they can be overwhelming!
It depends on your Sickbeard running and needs very little to do its work.

#!/bin/bash : <<‘END’ This script allows you to remove tv shows that have lived on your filesystem over x amount of days. It will also remove any nfo/tbn files associated with the episode if you are telling Sickbeard to populate them (I use the xbmc profile). By default, it will tell Sickbeard the status of the show is ignored. A couple important things: -For each show, you need to define the TVDBID as an argument to dowork UNLESS you utilize Sickbeard’s meta/art data, then this should work. As long as you have a “tvshow.nfo” in the root of your tv show directory!! -Depending on how you have your sickbeard setup, change the HOST variable…I have a reverse proxy setup so I need the /sickbeard part before the /api. You may want to do a simple api call using wget just to test your connect url. -One thing this doesn’t do is check if Sickbeard is up first. So make sure it is !!! -This script looks for and depends on a “.S02E9.” part of your episode name to exist. This is what it uses to inform Sickbeard. -It is assumed your video files are either avi, mp4, or mkv. You can add more at the end of the dowork function. Enjoy! END # Define our global vars specific to sickbeard APIKEY=0479d555c1405cf4561f9dc1d669c86 HOST=“” # This is the status we will set removed episodes to. STATUS=“ignored” dowork () { TVDBID=${1-$(cat “$SHOWROOT/tvshow.nfo” | grep “” | sed ’s///;s/<\/id>//’ | tr -d ‘ ’ | tr -d ‘\n’)} while IFS= read -d $’\0’ -r episode ; do echo “###### Starting….” echo “Grabbing our video file extension, season, and episode numbers..” EXT=$(echo -n $episode | sed -n ’s/..(…)$/\1/p’) NFO=$(echo -n $episode | sed “s/$EXT/nfo/”) TBN=$(echo -n $episode | sed “s/$EXT/tbn/”) SEASON=$(echo -n $episode | sed -n ’s/..S([0-9]+)E[0-9]+../\1/p’) EP=$(echo -n $episode | sed -n ’s/..S[0-9]+E([0-9]+)../\1/p’) echo “Calling Sickbeard API to change show $TVDBID episode S$SEASON E$EP status to $STATUS..” wget -qO /dev/null “http://$HOST/api/$APIKEY/?cmd=episode.setstatus&tvdbid=$TVDBID&season=$SEASON&episode=$EP&status=$STATUS&force=1” 2>&1 > /dev/null echo “Removing associated $EXT, .nfo, and .tbn files..” rm -f “$episode” [ -f “$NFO” ] && rm -f “$NFO” [ -f “$TBN” ] && rm -f “$TBN” echo “Finished processing $episode…next!” #exit ##enable to test one at a time if needed done < <(find “$SHOWROOT” ( -name ‘.mkv’ -or -name ‘.avi’ -or -name ‘.mp4’ ) -mtime +$DAYS -print0) } # Here you define the show and how many days old you want to keep. Anything older is removed. SHOWROOT=“/raid/tv/Red vs Blue”; DAYS=6; dowork #If I didn’t have a tvshow.nfo file: #SHOWROOT=“/raid/tv/Red vs Blue”; DAYS=6; dowork 12345

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.