2011-01-06, 21:05
Code:
read -p "Enter folder to scan:" Folder
read -p "Enter DBUserName:" DBUsername
read -p "Enter DBPassWord:" DBPassword
echo "creating list of files in $Folder"
ls -1 "$Folder" > ./tempList
while read line
do
test "${line:0:3}" != "mpg" && continue
FileName=`basename "$line"`
echo Processing "$FileName".mpg
#This part can be automated... it requires a bit of reference using
#Chanid=`mysql -u"$DBUserName" -p"$DBPassWord" -e \'use mythconverg; select chanid from recorded where basename like "$FileName";\'`|sed -n 2p
#Starttime=`mysql -u"$DBUserName" -p"$DBPassWord" -e \'use mythconverg; select starttime from recorded where basename like "$FileName";\'|sed -n 2p
mythcommflag -c $Chanid -s $Starttime --gencutlist
mythtranscode --chanid $Chanid --starttime $Starttime --mpeg2 --honorcutlist
rm "$Folder"/"$FileName".mpg
mv "$Folder"/"$FileName.mpg".tmp "$Folder"/"$FileName".mpg mythcommflag --file "$FileName".mpg --rebuild
NEWFILESIZE=`du -b "$Folder"/"$FileName".mpg | cut -f1`
echo "UPDATE recorded SET
#Same for starttime
basename='$FileName.mpg',filesize='$NEWFILESIZE',transcoded='1' WHERE chanid=\'$Chanid\' AND starttime=\'$Starttime\'" > update-database.sql
mysql --user=$DBUserName --password=$DBPassWord mythconverg < update-database.sql
rm "$Folder"/"$FileName".mpg*.png
done < ./tempList
echo "Removing previously created list of files in $Folder"
rm ./tempList
I'm not near a linux computer right now, so I can't test this out, but it should work with a bit of tweaking..
I don't really see what you're doing with all of this though.