better sync

This commit is contained in:
2026-06-17 16:38:39 -07:00
parent edbd144aa5
commit 1215fabd14

View File

@@ -10,24 +10,34 @@
# Adjust SHARE and SUBPATH to match your environment. # Adjust SHARE and SUBPATH to match your environment.
RECURSIVE="" RECURSIVE=""
SUBDIR=""
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--help|-h) --help|-h)
cat <<'EOF' cat <<'EOF'
Usage: sync-pictures [options] Usage: sync-pictures [options] [<subdir>]
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: 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 -h, --help Show this help message and exit
If <subdir> is given, sync only that subdirectory relative to ~/Pictures.
Use '.' to refer to ~/Pictures itself.
EOF EOF
exit 0 exit 0
;; ;;
--recursive|-r) --recursive|-r)
RECURSIVE=1 RECURSIVE=1
;; ;;
*)
[ -z "${SUBDIR}" ] && SUBDIR="${arg}" || {
echo "[sync-pictures] ERROR: Unexpected argument: ${arg}"
exit 1
}
;;
esac esac
done done
@@ -36,6 +46,10 @@ SUBPATH="Pictures"
MOUNTPOINT="${HOME}/mnt/miniShare1" MOUNTPOINT="${HOME}/mnt/miniShare1"
CREDENTIALS="${HOME}/.smb/mini.nas" CREDENTIALS="${HOME}/.smb/mini.nas"
SOURCE="${HOME}/Pictures" SOURCE="${HOME}/Pictures"
if [ -n "${SUBDIR}" ] && [ "${SUBDIR}" != "." ]; then
SOURCE="${SOURCE}/${SUBDIR}"
SUBPATH="${SUBPATH}/${SUBDIR}"
fi
START="$(date +%s)" START="$(date +%s)"
echo "[sync-pictures] Starting at $(date)" echo "[sync-pictures] Starting at $(date)"