]> arthur.barton.de Git - iPhone2Mac.git/commitdiff
New file format
authorAlexander Barton <alex@barton.de>
Wed, 16 Feb 2011 12:52:47 +0000 (13:52 +0100)
committerAlexander Barton <alex@barton.de>
Wed, 16 Feb 2011 12:52:47 +0000 (13:52 +0100)
The new file format allows us to sort entries correctly,
even if entry IDs are "out of order", for example after
changing devices.

iPhone2Mac.sh

index 0cf3ea44b554a9e829f169b672d58cdaf49cd0db..4070cc60c5b0d419683e6b0afd2183e0a096a8bf 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 # iPhone2Mac -- save call logs from iPhone backups
 #!/bin/bash
 #
 # iPhone2Mac -- save call logs from iPhone backups
-# Copyright (c)2009 Alexander Barton (alex@barton.de).
+# Copyright (c)2009-2011 Alexander Barton (alex@barton.de).
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -53,13 +53,27 @@ import_d() {
        fi
        for f in $call_db; do
                verbose "Dumping SQLite call databse \"$f\" ..."
        fi
        for f in $call_db; do
                verbose "Dumping SQLite call databse \"$f\" ..."
-               sqlite3 "$f" "select * from call;" >>"$CALL_TMP"
+               sqlite3 "$f" "select * from call;" | while read row; do
+                       IFS="|"
+                       arr=($row)
+                       unset IFS
+
+                       rowid=${arr[0]}
+                       address=${arr[1]}
+                       date=${arr[2]}
+                       duration=${arr[3]}
+                       flags=${arr[4]}
+                       id=${arr[5]}
+
+                       echo "$date|$rowid|$address|$duration|$flags|$id" \
+                         >>"$CALL_TMP"
+               done
        done
        verbose "Sorting plain ASCII call log ..."
        done
        verbose "Sorting plain ASCII call log ..."
-       sort -u "$CALL_TMP" >"$CALL_LOG"
+       sort -un "$CALL_TMP" >"$CALL_LOG"
        rm -f "$CALL_TMP"
        rm -f "$CALL_TMP"
-       first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
-       last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f3` "+%Y-%m-%d %H:%M")
+       first_d=$(date -r `head -1 "$CALL_LOG" | cut -d'|' -f1` "+%Y-%m-%d %H:%M")
+       last_d=$(date -r `tail -1 "$CALL_LOG" | cut -d'|' -f1` "+%Y-%m-%d %H:%M")
        message `wc -l "$CALL_LOG" | awk '{print \$1}'`" unique entries logged, from $first_d to $last_d."
 }
 
        message `wc -l "$CALL_LOG" | awk '{print \$1}'`" unique entries logged, from $first_d to $last_d."
 }