<span style="color:#323232;">#!/bin/bash
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Create a temporary file for storing file checksums
</span><span style="color:#323232;">tempfile=$(mktemp)
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Generate MD5 checksums for all files in the current directory and its sub-directories
</span><span style="color:#323232;">find . -type f -exec md5sum '{}' ; | sort > $tempfile
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Detect and delete duplicates
</span><span style="color:#323232;">awk 'BEGIN {
</span><span style="color:#323232;"> lasthash = "";
</span><span style="color:#323232;"> lastfile = "";
</span><span style="color:#323232;">}
</span><span style="color:#323232;">{
</span><span style="color:#323232;"> if ($1 == lasthash) {
</span><span style="color:#323232;"> print "Deleting duplicate file: " $2;
</span><span style="color:#323232;"> system("rm -f ""$2""");
</span><span style="color:#323232;"> } else {
</span><span style="color:#323232;"> lasthash = $1;
</span><span style="color:#323232;"> lastfile = $2;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">}' $tempfile
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Clean up
</span><span style="color:#323232;">rm -f $tempfile
</span>
This script can be run with Termux from the root of your internal storage. Usually /sdcard or /storage/emulated/0. Do not confuse this with running from root if you are rooted.
Before using a script that interacts with your files you should backup anything that is important just in case.
You can run the script and see what files the script would delete without actually deleting them. I would recommend doing this as I have not tested this script.