#!/bin/bash # # Clean up all the machine generated files in a directory, leaving only the # hand constructed or downloaded files and the final .avi file. Do nothing # if the directory is missing essential files. # mydir=`dirname $0` PATH=`$mydir/echo-path` export PATH # echo Cleaning directory `/bin/pwd` mpgcount=`ls -1 *.mpg | wc -l` if [ "$mpgcount" = "1" ] then basefile=`basename *.mpg .mpg` if [ -f "$basefile.mpg" ] then : else echo \*\*\* "$basefile.mpg" is not a regular file 1>&2 exit 2 fi if [ -f "$basefile.avi" ] then : else echo \*\*\* Missing "$basefile.avi" 1>&2 exit 2 fi if [ -f "$basefile.keep" ] then : else echo \*\*\* Missing "$basefile.keep" 1>&2 exit 2 fi if [ -f "info.txt" ] then : else echo \*\*\* Missing info.txt 1>&2 exit 2 fi for i in tempdir-* "time-$basefile.avi" "hq-$basefile.avi" \ "$basefile.concat" "$basefile.edl" "$basefile.csv" \ "pcm-$basefile.avi" "aud-$basefile.wav" "guess-$basefile.keep" \ work.log guess.log runseg.log gentime.log webm.out do if [ -d "$i" ] then echo Removing directory $i rm -rf "$i" else if [ -f "$i" ] then echo Removing file $i rm -f "$i" fi fi done else echo \*\*\* Count of mpg files \($mpgcount\) is not 1 1>&2 exit 2 fi