added keepalive tool
[tridge/junkcode.git] / photos_grab
1 #!/bin/sh
2
3 mkdir -p $HOME/photos/s40
4
5 cd $HOME/photos/s40 || exit 1
6
7 LIST=`gphoto2 --port usb -L 2> /dev/null | grep '^#' | awk '{print $2}'`
8
9 if [ -z "$LIST" ]; then
10     echo no photos
11     exit 1
12 fi
13
14 n1=1
15 n2=0
16 for f in $LIST; do
17     n2=`expr $n2 + 1`;
18     if [ ! -f $f ]; then
19         echo $f
20     else
21         echo Already have $f
22         if [ $n2 -eq $n1 ]; then
23             n1=`expr $n2 + 1`
24         fi
25     fi
26 done
27
28 if [ $n2 -ge $n1 ]; then
29   gphoto2 --port usb -p $n1-$n2
30 fi
31
32 echo -n 'delete photos? [y/N] '
33 read ans
34 if [ "$ans" = y ]; then
35     gphoto2 --port usb -D
36 fi