I have multiple directories containing multiple images, and some of these directories have duplicate images. I want to find all duplicate images within the same directory and delete them. Below is my code.
I'm having a problem with deleting the duplicate image. the code can identify duplicate files, but when it tries to delete it it shows this message"rm: cannot remove 'FILENAME': No such file or directory"
for dir in *; do
count=1
for file in $dir/*.*; do
md5sum * | sort | awk 'BEGIN{lasthash = ""} $1 == lasthash {print $2} {lasthash = $1}' | xargs rm
let count=count+1
done
done