#!/bin/bash dir="/export/docker/storage/other-videos/AFL" for year in `ls $dir` do echo "dir=$dir/$year" for file in `ls $dir/$year` do if [ $year == 2020 ]; then echo "Skip 2020 for now, its a mess" continue fi echo "$file -> need to change the mp4 in the db (it will ref mpg)" echo " and do the right hash: $hash" dirname=`dirname $file` basename=`basename $file` base="${basename%.*}" intid="" intid=$(echo -n "select intid from videometadata where filename = 'Football/$year/$base.mpg'" \ | mysql --user=mythtv --password=mythtv mythconverg | tail -n1) if [ -z $intid ]; then echo "-- hmm, cant find the mpg, try a mp4?" intid=$(echo -n "select intid from videometadata where filename = 'Football/$year/$base.mp4'" \ | mysql --user=mythtv --password=mythtv mythconverg | tail -n1) if [ -z $intid ]; then echo "-- hmm, cant find the mpg, try an avi?" intid=$(echo -n "select intid from videometadata where filename = 'Football/$year/$base.avi'" \ | mysql --user=mythtv --password=mythtv mythconverg | tail -n1) if [ -z $intid ]; then echo "-- hmm, cant find the mpg, try an iso?" intid=$(echo -n "select intid from videometadata where filename = 'Football/$year/$base.iso'" \ | mysql --user=mythtv --password=mythtv mythconverg | tail -n1) if [ -z $intid ]; then echo "-- hmm, cant find the mpg, try an mkv?" intid=$(echo -n "select intid from videometadata where filename = 'Football/$year/$base.mkv'" \ | mysql --user=mythtv --password=mythtv mythconverg | tail -n1) if [ -z $intid ]; then echo "*********** Seems we cant find: $dir/$year/$base.mp[g4]? in the DB" exit 1 fi fi fi fi fi echo "Found in DB: $intid" hash=`/home/ddp/bin/hash_4_myth.pl "$dir/$year/$file"` echo "update videometadata set hash = '$hash', filename='AFL/$year/$file' where intid=$intid" \ | mysql --user=mythtv --password=mythtv mythconverg done done