Rename files based on checksum
First of all, I'm not going to claim that this is the most profound solution but, here is one way to do it.
Let's say you have the file with the checksum and filenames called filelist.txt
then you could use something like:
while read -r checksum fname; do for f in file*; do if [[ $checksum == $(md5sum "$f" | cut -d' ' -f1) ]]; then mv "$f" "$fname"; fi ; done ; done < filelist.txt
I haven't fully tested, it's just theoretically working. Substitute where needed:
#! /bin/bash
for II in *
do
if [ -f "$II" ]; then
TMPV=$(md5sum "$II")
MD="${TMPV%\ \ *}"
TMPV=$(grep "$MD" hashes.txt)
if [ ! -z "$TMPV" ]; then
FN="${TMPV#*\ \ }"
echo "Found: $II"
echo "MD5 is: $MD"
echo "Which matches $FN in hashes database"
echo "Will Rename $II TO $FN"
echo ""
# CAREFUL, RENAME CMD: mv "$II" "$FN"
fi;
fi;
done;
As I say, haven't tested it, but it seemed to work on my box.