-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalidate_pic.sh
More file actions
executable file
·42 lines (34 loc) · 909 Bytes
/
validate_pic.sh
File metadata and controls
executable file
·42 lines (34 loc) · 909 Bytes
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
#!/bin/bash
## every 15mins, check log and downloaded files
DIR=/home/pi/public_html/lapse
a=`tail -1 $DIR/logs/gphoto2.log`
#echo $a
q="IMG"
b=${q}${a#*${q}}
#echo $b
d=`expr ${b:4:4} - 1`
e="IMG_$d.JPG"
#e="IMG_1901.JPG"
if [[ "$e" == *01.JPG ]]
then
echo "ok!"
f=$(/usr/bin/gphoto2 -L | grep $e | awk '{print $1}' | cut -b 2-10)
if [ -z "$f" ]
then
echo "not exists on camera $e"
exit 0
fi
env LANG=C /usr/bin/gphoto2 \
--quiet \
--get-file=$f \
--hook-script=$DIR/gphoto2-hook-script.sh \
--filename "G6_%Y%m%d-%H%M-%f.%C" \
>> $DIR/logs/gphoto2.log 2>&1
## tail -2 logs/gphoto2.log | head -1 ## to acquire folder name
g=`tail -2 $DIR/logs/gphoto2.log | head -1` ## "Downloading 'IMG_1801.JPG' from folder '/store_00010001/DCIM/118CANON'..."
h="store"
i=${h}${g#*${h}}
j=/${i:0:28}
env LANG=C /usr/bin/gphoto2 --delete-file=1 --folder=$j >> $DIR/logs/gphoto2-delete.log
fi
exit 0