diff --git a/comfyui-sync b/comfyui-sync index 71cf1c0..8344732 100755 --- a/comfyui-sync +++ b/comfyui-sync @@ -1,7 +1,9 @@ #!/bin/bash set -euo pipefail -SOURCE="$HOME/ComfyUI/output" +OUTPUT_SOURCE="$HOME/ComfyUI/output" +VIDEO_SOURCE="$HOME/ComfyUI/videos" +AUDIO_SOURCE="$HOME/ComfyUI/audio" SHARE_DIR="/mini.nas/miniShare1/Pictures" STATE_FILE="$HOME/.local/state/comfyui-sync.state" NEATCLI="$(command -v /home/linuxbrew/.linuxbrew/bin/neatcli || true)" @@ -10,11 +12,6 @@ ORGANIZE_SCRIPT="$HOME/git/schmeeve-toolz/organize-images" mkdir -p "$(dirname "$STATE_FILE")" -if [ ! -d "$SOURCE" ]; then - echo "[comfyui-sync] ERROR: Source $SOURCE does not exist" - exit 1 -fi - if [ ! -d "$SHARE_DIR" ]; then echo "[comfyui-sync] ERROR: Share dir $SHARE_DIR does not exist" exit 1 @@ -22,7 +19,11 @@ fi echo "[comfyui-sync] Starting at $(date)" -current_files=$(find "$SOURCE" -maxdepth 1 -type f -printf '%f\n' | sort) +current_files=$( { + find "$OUTPUT_SOURCE" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null + find "$VIDEO_SOURCE" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null + find "$AUDIO_SOURCE" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null +} | sort) if [ -f "$STATE_FILE" ]; then new_files=$(comm -13 <(sort "$STATE_FILE") <(echo "$current_files")) @@ -37,7 +38,13 @@ if [ "$new_count" -gt 0 ]; then echo "[comfyui-sync] Copying $new_count new file(s)..." while IFS= read -r f; do [ -z "$f" ] && continue - cp "$SOURCE/$f" "$SHARE_DIR/" + if [ -f "$OUTPUT_SOURCE/$f" ]; then + cp "$OUTPUT_SOURCE/$f" "$SHARE_DIR/" + elif [ -f "$VIDEO_SOURCE/$f" ]; then + cp "$VIDEO_SOURCE/$f" "$SHARE_DIR/" + elif [ -f "$AUDIO_SOURCE/$f" ]; then + cp "$AUDIO_SOURCE/$f" "$SHARE_DIR/" + fi done <<<"$new_files" echo "$current_files" >"$STATE_FILE"