#!/bin/bash dir="/myth/opt/storage/other-videos/AFL/" for year in `ls $dir` do echo "dir=/$dir/$year" for file in `ls $dir/$year` do # title=`MP4Box $dir/$year/$file -info 2>&1 | grep Name: | cut -f2- -d:` # echo -n " file=$file - title=$title" # if [[ ${title} =~ $year.AFL.(.*) ]] # then # new_title=${BASH_REMATCH[1]} # echo -n ", new_title=$new_title" # MP4Box -itags name="$new_title" $dir/$year/$file # fi desc=`ffprobe $dir/$year/$file 2>&1 | grep description | cut -f2- -d:` if [[ ${desc} =~ (.*)\\n\\n(.*)\\n(.*) ]] then ground=${BASH_REMATCH[1]} home=${BASH_REMATCH[2]} home=`echo $home | cut -f2- -d' '` away=${BASH_REMATCH[3]} echo "Need to fix $file: $home $away $ground (was: $desc)" mv $dir/$year/$file /myth/archive/$file ffmpeg -i /myth/archive/$file -codec copy -metadata description="$home $away $ground" $dir/$year/$file fi echo "" done done