Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #
  4. # A script to download photos and videos you took with your cellphone via Bluetooth. It downloads only files lacking locally
  5. # It is nice to put it in crontab
  6. # You phone must be paired with computer already
  7. # The phone is not necessarily must be blutooth discoverable
  8. #
  9. # This script is GNU/GPLv3 Free Software
  10. #
  11. # Anton Tesla Starikov, teesla@gmail.com
  12. #
  13.  
  14. phonemac="00:1D:28:FA:A2:AB"
  15. phonedir="/Memory Stick/DCIM/100MSDCF"
  16. localdir="/home/tesla/Pictures/Phone/"
  17. localtmp="/tmp/"
  18.  
  19. mkdir $localdir
  20.  
  21. #get list from phone
  22. obexftp -b $phonemac -c "$phonedir" -l | grep "file name" | awk -F\" '{print $2}' | sort > $localtmp.phonelist.tmp
  23.  
  24. #get list from HDD
  25. ls -1 $localdir | sort > $localtmp.hddlist.tmp
  26.  
  27. #findout what we are lacking locally
  28. #sorting in back order since usually we need newer files most, so we get them first
  29. diff $localtmp.phonelist.tmp $localtmp.hddlist.tmp|grep "<"|awk '{print $NF}' | sort -r > $localtmp.difference.tmp
  30.  
  31. #if there is anything we are lacking
  32. if [ -s $localtmp.difference.tmp ]; then
  33.     cd $localdir
  34.     #for each file lacking
  35.     while read line; do
  36.     touch $line
  37.     #get it
  38.     #you can commentout obexftp if you dont really want all those files but rather their placeholders
  39.     obexftp -b $phonemac -c "$phonedir" -g $line
  40.     done < $localtmp.difference.tmp
  41. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement