-
Notifications
You must be signed in to change notification settings - Fork 0
/
pullcalls.sh
62 lines (44 loc) · 1.18 KB
/
pullcalls.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
#!/bin/bash
location=/storage/self/primary/MIUI/sound_recorder/call_rec/;
destination=~/Desktop/Calls/;
# Can change Timezone
todaysdate=$(date --date='TZ="Asia/Karachi" now' +%Y%m%d);
# Don't change this
callsfile=$destination'calls.txt';
cd $destination;
adb start-server
adb devices -l
read -p "Press any key when authorized on phone:"
adb shell ls $location > $callsfile
if [[ -r lastdate.txt ]]
then
lastdate=$(date -d $( cat lastdate.txt ));
lastdateepoch=$(date -d $( cat lastdate.txt ) +%s );
else
lastdate=$(date -d "20000101");
fi
echo Last Date: $lastdate
echo Last Date Epoch: $lastdateepoch
c=1;
while read -r callinfo; do
numberdate=$( echo $callinfo | cut -d '_' -f2 | cut -c 1-8 );
# echo $numberdate
dateobj=$( date -d $numberdate +%s);
if [[ $lastdateepoch < $dateobj ]]
then
echo $c: Copying: $callinfo
echo
((c++));
adb pull "${location}${callinfo}"
echo
echo
fi
done <$callsfile
read -p "Do you want to update date for next backup? (y/n): " changedate;
if [[ changedate -eq 'y' ]]
then
echo $todaysdate > lastdate.txt
echo "Date updated!"
else
echo "Date not updated!"
fi