DRY_RUN=true if [[ "${1:-}" == "--apply" ]]; then DRY_RUN=false echo "--- RUNNING IN LIVE MODE: Files will be renamed ---" else echo "--- RUNNING IN DRY-RUN MODE: No changes will be made ---" echo "--- Use 'syncthing-resolve-conflicts --apply' to perform the rename ---" fi find . -type f -name "*sync-conflict*" ! -name "*.db" -print0 | while IFS= read -r -d '' file; do new=$(echo "$file" | sed -E 's/\.sync-conflict-[0-9]{8}-[0-9]{6}-[A-Z0-9]+//') if [[ "$file" != "$new" ]]; then if [ "$DRY_RUN" = true ]; then echo "[DRY-RUN] Would rename: '$file' -> '$new'" else if [[ -f "$new" ]]; then echo "[SKIP] Target already exists: '$new'" else echo "Renaming: '$file' -> '$new'" mv "$file" "$new" fi fi fi done echo "--- Done ---"