blob: 7c8e6ab2b282675e6ad04cf39024112d879969c8 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#!/bin/bash
usage() {
echo "Usage: $0 [--dev device] [--deleteaftercopy] [--noraw] [--nojpg] [--nomov] [--notimeinstamp]"
exit 0
}
### default values ###
# device #
sddev=/dev/mmcblk0p1
# folder for pictures
picdir="/home/lookshe/Bilder/d5100"
# file endings #
end_jpg=".JPG"
end_raw=".NEF"
end_mov=".MOV"
# delete and timestamp #
deleteaftercopy=0
notimeinstamp=0
# which to copy #
copyraw=1
copyjpg=1
copymov=1
# we work with nice #
nicelevel=19
# parse arguments #
#for arg in "$@"
while [ "$1" != "" ]
do
case $1 in
--deleteaftercopy)
deleteaftercopy=1
;;
--noraw)
copyraw=0
;;
--nojpg)
copyjpg=0
;;
--nomov)
copymov=0
;;
--notimeinstamp)
notimeinstamp=1
;;
--dev)
shift
sddev="$1"
;;
*)
usage
;;
esac
shift
done
# check for inserted card #
if [ ! -e "$sddev" ]
then
echo "sd card not inserted!"
exit 1
fi
# check if mounted #
#mountpoint=$(mount | grep "$sddev" | awk '{print $3}')
mountpoint=$(mount | grep "$sddev" | cut -d" " -f3- | sed 's/ type.*//')
if [ ! -e "$mountpoint" ]
then
echo "sd card not mounted!"
exit 2
fi
if [ $notimeinstamp -eq 1 ]
then
stamp=$(date +%F)
else
stamp=$(date +%F_%H-%M)
fi
copydir="$picdir/$stamp"
if [ -e "copydir" ]
then
echo "$copydir already exists"
exit 3
else
mkdir "$copydir"
fi
echo "Start copying files:"
if [ $copyjpg -eq 1 ]
then
mkdir "$copydir/pic"
find "$mountpoint" -name "*$end_jpg" | while read file
do
nice -n $nicelevel cp -v "$file" "$copydir/pic"
if [ $? -eq 0 -a $deleteaftercopy -eq 1 ]
then
nice -n $nicelevel rm "$file"
fi
done
fi
if [ $copyraw -eq 1 ]
then
mkdir "$copydir/raw"
find "$mountpoint" -name "*$end_raw" | while read file
do
nice -n $nicelevel cp -v "$file" "$copydir/raw"
if [ $? -eq 0 -a $deleteaftercopy -eq 1 ]
then
nice -n $nicelevel rm "$file"
fi
done
fi
if [ $copymov -eq 1 ]
then
mkdir "$copydir/mov"
find "$mountpoint" -name "*$end_mov" | while read file
do
nice -n $nicelevel cp -v "$file" "$copydir/mov"
if [ $? -eq 0 -a $deleteaftercopy -eq 1 ]
then
nice -n $nicelevel rm "$file"
fi
done
fi
|