dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

sync_phone_pictures (761B)


      1 #!/usr/bin/env bash
      2 if ! command -v rsync &>/dev/null; then
      3   echo "rsync not installed." >&2
      4   exit 1
      5 fi
      6 
      7 do_rsync() {
      8   rsync -aP --stats  "$@"
      9 }
     10 die() {
     11   echo "$1" >&2
     12   exit 1
     13 }
     14 set_photo_dir() {
     15   if [ -d "$HOME/Pictures/Imports/" ]; then
     16     PHOTO_IMPORT_DIR="$HOME/Pictures/Imports/"
     17   else
     18     read -rp "Import to: " PHOTO_IMPORT_DIR
     19     [ -d "$PHOTO_IMPORT_DIR" ] || die "$PHOTO_IMPORT_DIR does not exist or is not a directory."
     20   fi
     21 }
     22 PHONE_DIR="$HOME/phone/Phone/DCIM"
     23 
     24 [ -d "$PHONE_DIR" ] || die "Phone not present, expected at $PHONE_DIR"
     25 
     26 less -fR <(do_rsync "$PHOTO_IMPORT_DIR"/ "$PHONE_DIR" -n)
     27 
     28 read -rp "Execute? [Y/n]" -n 1 -s conf
     29 echo
     30 
     31 case "$conf" in
     32   Y|y) do_rsync "$PHONE_DIR" "$PHOTO_IMPORT_DIR"/;;
     33   *) die "User cancelled.";;
     34 esac
     35