UPDATE: I made some improvements and will now catch both shows that start with letters or numbers.
ANOTHER UPDATE: Turns out i was truncating the show name, it is fixed and I have updated the script and link to too.

I updated my script to be totally generic now. It does not depend on matching the names of any specific TV shows now, since I know the filename will always contain SxxExx to indicate Season and Episode, I filter that way. If the directory for that show already exists it will simply move the file there, if it doesn’t it will create a new one. Otherwise, if it isn’t a TV show, it goes to the Movie directory. Also, since I’m now using ushare to serve media to my xbox 360, I put a wget call in to the ushare web port to update the files so the xbox picks them up immediately over uPnP.

# Jay Holler 09-10-2009
# Find *.avi files in the Downloads directory and move them to
# the appropriate folder on the NFS share


cd /home/jayholler/Downloads

for i in *.avi

if [[ “$myFile” =~ ([A-Za-z0-9\.]*)\.(S..E..).avi ]] ; then
ShowName=$(echo $PreShowName | sed ‘s/\./ /g’)
echo “[*] A new episode of $ShowName is ready for your enjoyment: $File” > /tmp/emailmessage.txt && sleep 2
[ -d “$storageDir/$ShowName” ] || mkdir -v “$storageDir/$ShowName”
mv -v $myFile “$storageDir/$ShowName/$File”
wget http://localhost:49153/web/ushare.cgi?action=refresh -o /dev/null -P /dev/null
echo “[+] $myFile does not match our TV shows, pushing it to /storage/Movies on lunchbox” > /tmp/emailmessage.txt
mv -v “$myFile” /storage/Movies/$myFile
exit 0

Here’s the same thing in nicer formatting:


Author: jayholler

A technology lover living in California with my wife and two children.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s