#!/bin/bash ids=$(echo -n "select intid from videometadata where filename like 'Football%'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n+2) echo $ids for id in $ids; do title=$(echo -n "select director from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) filename=$(echo -n "select filename from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) [[ ${filename} =~ Football/(.*)/.* ]] year=${BASH_REMATCH[1]} echo "processing ($filename) -- $id: $title" input_filename="/export/myth/videos/$filename" input_dirname=`dirname $filename` input_basename=`basename $input_filename` input_base="${input_basename%.*}" if [ ! -f "/export/myth/videos/$input_dirname/$input_base.mp4" ]; then echo "***** DID NOT FIND $dirname/$input_base.mp4" exit 1 fi $(echo -n "update videometadata set filename='$input_dirname/$input_base.mp4' where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n+2) done