I do not want to completely solve this problem, but here are some useful ingredients that you can try and integrate:
find /path -type f
you can iterate over a list like this
for f in $(find /path -type f -name '*.jpg'); do
...
done
, .
base=$(basename $f)
full_path=$f
hash=$(echo $f | md5sum | awk '{print $1}')
, , , .
, , , . , .
, , : , , :
sort -k2 list.txt | column -t > list.sorted.txt
sort -k2 -u list.txt | column -t > list.sorted.uniq.txt
, basename
diff list.sorted.txt list.sorted.uniq.txt
. MD5, , , , mv, rm, ln ..