-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogify.sh
executable file
·68 lines (59 loc) · 1.49 KB
/
logify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
# renames and organizes personal log files
LOGPATH=~/Videos/Log
movelog() {
LOGFILE=$1
FILEDATE=$(date +"%Y%m%d%H%M" -r $LOGFILE)
LOGEXT=${LOGFILE##*.}
DESTFILE=$LOGPATH/$FILEDATE.$LOGEXT
THUMBEXT=THM
THUMBFILE=${LOGFILE%.*}.$THUMBEXT
if [ "$LOGEXT" = "MOV" ] || [ "$LOGEXT" = "mov" ] || [ "$LOGEXT" = "AVI" ] || [ "$LOGEXT" = "avi" ];then
echo checking for $DESTFILE
if [ -f $DESTFILE ]; then
echo "Destination file already exists, appending current date..."
DESTFILE="$LOGPATH/$FILEPATH-$(date +"%Y%m%d%H%M").$LOGEXT"
else
echo "all clear!"
fi
cp $LOGFILE $DESTFILE
if [ -f $THUMBFILE ]; then
rm $THUMBFILE
echo cleaned up $THUMBFILE
# else
# echo $THUMBFILE not found
fi
echo "moved $LOGFILE to $DESTFILE"
OGGLOG=${DESTFILE%.*}.ogv
echo "$OGGLOG"
if [ -f $OGGLOG ]; then
echo "Destination file already exists, appending current date..."
OGGLOG="${OGGLOG%.*}-$(date +"%Y%m%d%H%M").ogv"
echo "$OGGLOG"
fi
echo "Renencoding file to OGV..."
ffmpeg2theora $DESTFILE -o $OGGLOG > /dev/null 2>&1
echo "Reencode complete!"
OUT=$?
if [ $OUT -eq 0 ]; then
echo "lookin' good, cleaning up source $DESTFILE"
trash $DESTFILE
else
echo "Something weird happened, ffmpeg2theora exit status $out. Please check files"
fi
fi
}
if [ -d "$1" ]; then
INPUTFILES=$1/*
for f in $INPUTFILES; do
if [ ${f##*.} = MOV ]; then
movelog $f
else
echo "not an appropriate file type"
fi
done
else
movelog $1
fi
echo
echo "all done!"