I would strongly recommend a total backup of all your data before proceeding. After that, create a new account and play-around from the new account.
"Advanced Bash-Scripting Guide" covers everything with numerous examples. http://www.tldp.org/guides.html It the fist manual listed. Bash is powerful but exacting.
Should be able to find what you need in the existing code. The code eliminates all duplicate files by moving only one copy of each unique file to a new directory. ( It's been 9 years since I worked on this code. It deletes things too. ) The existing code creates hashes of all the files in a folder. It compares the hashes to find duplicates. You should be able to substitute a rename at this point. It has code to create a unique name for some reason. The code contains extensive debugging code to create a log of it's doing. Turn on the log and follow what it is doing.
https://pastebin.com/raw/RQTXZVt6
Here is an example of the output:
additional references.
This script is a partial rewrite of the code from JulieJulieJulie's Consolidate17 script.
See:
http://discussions.apple.com/message.jspa?messageID=11577992#11577992
additional discussion:
https://discussions.apple.com/thread/2434165?start=0&tstart=0