feat(searc_image_duplcates): loof for hash of image A in search_dir

This commit is contained in:
lucas committed 2026-11-05 10:30:25 +01:00
1 parent 6a771237b5
commit 8bb529a063
1 file changed
+53
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
target="/data/nextcloud/syncuser/pictures/Favorites/Mimi/2010_Eichgraben01.jpg"
base_dir="/data/immich/pictures/Unsere Family"
target_hash=$(sha256sum "$target" | awk '{print $1}')
mapfile -t search_dirs < <(
find "$base_dir" -mindepth 1 -maxdepth 2 -type d \
-regextype posix-extended \
-regex '.*/20(10)$' \
| sort
)
total=$(find "${search_dirs[@]}" -type f \( \
-iname '*.jpg' -o \
-iname '*.jpeg' -o \
-iname '*.png' -o \
-iname '*.heic' \
\) | wc -l)
count=0
found=0
echo "process: $target"
echo "Search for hash of $(basename "$target") in:"
printf ' %s\n' "${search_dirs[@]}"
echo "Total images: $total"
while IFS= read -r -d '' file; do
((count++))
if (( count % 100 == 0 || count == total )); then
printf "Processed %d/%d images (%.1f%%)\n" \
"$count" "$total" "$((count * 1000 / total))e-1"
fi
file_hash=$(sha256sum "$file" | awk '{print $1}')
if [[ "$file_hash" == "$target_hash" ]]; then
echo "FOUND: $file"
found=1
fi
done < <(
find "${search_dirs[@]}" -type f \( \
-iname '*.jpg' -o \
-iname '*.jpeg' -o \
-iname '*.png' -o \
-iname '*.heic' \
\) -print0
)
echo "Done. Checked $count/$total images."
((found)) || echo "No matching image found."