commit 81954ffb14e5dfc6ddfce4f34324544fe4ba8b01 parent 710f03aa318d3a9e57b1b7ee0a6ca8c483807334 Author: Jacob R. Edwards <n/a> Date: Sun, 13 Feb 2022 20:10:47 -0800 Add script to pull photographs from a camera Diffstat:
| A | local/bin/bin/panamerge | | | 32 | ++++++++++++++++++++++++++++++++ |
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/panamerge b/local/bin/bin/panamerge @@ -0,0 +1,32 @@ +#!/bin/sh -e +# Copyright 2021 Jacob R. Edwards +# Merge camera filesystem into photographs directory +# (specifically the Panasonic DMC-ZS8) + +srcdir="${1:-/mnt/}" +dstdir="${2:-$HOME/own/photos}" +fmt="%Y/%m/%d/%H%M%S" + +! test -d "$dstdir" && { + echo 'no dstdir' 1>&2 + exit 1 +} + +# you could skip the first few bytes of magic +sample() dd status=none if="$1" bs=128 count=1 + +compare() { + test "$(sample "$1")" = "$(sample "$2")" +} + +for src in "$srcdir"/DCIM/*/* +do + dst="$dstdir/$(stat -t "$fmt" -f %Sm "$src")-$(basename "$src" | tr '[:upper:]' '[:lower:]')" + mkdir -p "$(dirname "$dst")" + if ! test -f "$dst"; then + echo "$dst" + cp -pi "$src" "$dst" + elif ! compare "$src" "$dst"; then + echo "$dst: Exists and is different" 1>&2 + fi +done