From 1215fabd147dde18f4ec0fd6fc45cc0bb043e035 Mon Sep 17 00:00:00 2001 From: schmeeve Date: Wed, 17 Jun 2026 16:38:39 -0700 Subject: [PATCH] better sync --- sync-pictures | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sync-pictures b/sync-pictures index a285eca..afcfa8c 100755 --- a/sync-pictures +++ b/sync-pictures @@ -10,24 +10,34 @@ # Adjust SHARE and SUBPATH to match your environment. RECURSIVE="" +SUBDIR="" for arg in "$@"; do case "$arg" in --help|-h) cat <<'EOF' -Usage: sync-pictures [options] +Usage: sync-pictures [options] [] -Sync ~/Pictures to a NAS share and run neatcli organize on both ends. +Sync ~/Pictures (or a subdirectory) to a NAS share and run neatcli organize on both ends. Options: - -r, --recursive Sync subdirectories recursively (default: top-level files only) + -r, --recursive Sync recursively (default: top-level files only) -h, --help Show this help message and exit + +If is given, sync only that subdirectory relative to ~/Pictures. +Use '.' to refer to ~/Pictures itself. EOF exit 0 ;; --recursive|-r) RECURSIVE=1 ;; + *) + [ -z "${SUBDIR}" ] && SUBDIR="${arg}" || { + echo "[sync-pictures] ERROR: Unexpected argument: ${arg}" + exit 1 + } + ;; esac done @@ -36,6 +46,10 @@ SUBPATH="Pictures" MOUNTPOINT="${HOME}/mnt/miniShare1" CREDENTIALS="${HOME}/.smb/mini.nas" SOURCE="${HOME}/Pictures" +if [ -n "${SUBDIR}" ] && [ "${SUBDIR}" != "." ]; then + SOURCE="${SOURCE}/${SUBDIR}" + SUBPATH="${SUBPATH}/${SUBDIR}" +fi START="$(date +%s)" echo "[sync-pictures] Starting at $(date)"