#!/usr/bin/env zsh set -x set -e set -o nullglob YYYYMMDD="$(date "+%Y-%m-%d")" function downloadPhotos() { SRC=(/Volumes/*/DCIM) if [[ ! -d "$SRC" ]]; then echo "no photos" > /dev/stderr return fi DST="$HOME/Library/Syncthing/folders/LightroomMasters-CurrentYear/toimport" du -sh "$SRC" rsync -ah --no-inc-recursive --info=progress2 --remove-source-files "$SRC"/ $DST/$YYYYMMDD/ cd "$DST/$YYYYMMDD" mv */* . f2 -r '../{{mtime.YYYY}}/{{mtime.YYYY}}-{{mtime.MM}}/{{mtime.YYYY}}-{{mtime.MM}}-{{mtime.DD}}/{{mtime.YYYY}}-{{mtime.MM}}-{{mtime.DD}}.{{x.model}}.{{f}}.{{hash.sha256}}{{ext}}' -x --verbose } function downloadVideos() { SRC=(/Volumes/*/PRIVATE/M4ROOT/CLIP) if [[ ! -d "$SRC" ]]; then echo "no videos" > /dev/stderr return fi DST="$HOME/_TODO/$YYYYMMDD-video-import/" mkdir -p "$DST" du -sh "$SRC" rsync -ah --no-inc-recursive --info=progress2 --remove-source-files "$SRC"/ $DST/ cd "$DST" #mv */* . f2 -r '{{mtime.YYYY}}/{{mtime.YYYY}}-{{mtime.MM}}/{{mtime.YYYY}}-{{mtime.MM}}-{{mtime.DD}}/{{mtime.YYYY}}-{{mtime.MM}}-{{mtime.DD}}.{{f}}.{{hash.sha256}}{{ext}}' -x --verbose } function main() { # FIXME this doesn't work if there are no photos on the card but the # DCIM dir exists downloadPhotos downloadVideos } main