Files
Server-scripts/file_processing/search_for_image_duplicates.sh
T

54 lines
1.3 KiB
Bash

#!/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."